aboutsummaryrefslogtreecommitdiff
path: root/challenge-215/deadmarshal/perl/ch-1.pl
blob: 550a63f2b13d75e410706f56ef21391de32edb0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env perl
use strict;
use warnings;

sub is_alphabetical_order{
  my @arr = split '',$_[0];
  map{return 0 if $arr[$_] lt $arr[$_-1]} 1..$#arr;
  1
};

sub odd_one_out{
  my $count = 0;
  map{$count++ unless is_alphabetical_order $_} @{$_[0]};
  $count
}

printf "%d\n", odd_one_out(['abc', 'xyz', 'tsu']);
printf "%d\n", odd_one_out(['rat', 'cab', 'dad']);
printf "%d\n", odd_one_out(['x','y','z']);