diff options
Diffstat (limited to 'challenge-215/robert-dicicco/perl/ch-1.pl')
| -rw-r--r-- | challenge-215/robert-dicicco/perl/ch-1.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/challenge-215/robert-dicicco/perl/ch-1.pl b/challenge-215/robert-dicicco/perl/ch-1.pl new file mode 100644 index 0000000000..5e2b7f6ea8 --- /dev/null +++ b/challenge-215/robert-dicicco/perl/ch-1.pl @@ -0,0 +1,41 @@ +#!/usr/bin/enc perl +=begin pod +---------------------------------------- +AUTHOR: Robert DiCicco +DATE : 2023-05-01 +Challenge 215 Odd One Out ( Perl ) +---------------------------------------- +=cut +use strict; +use warnings; +use feature 'say'; + +my @words = (["abc", "xyz", "tsu"],["rat", "cab", "dad"],["x", "y", "z"]); + +for my $wds (@words) { + my $cnt = 0; + say "Input: \@words = (@$wds)"; + for my $w (@$wds) { + my $w_sorted = join("",sort(split(//,$w))); + $cnt++ if ($w ne $w_sorted); + } + say "Output: $cnt\n"; +} + +=begin pod +---------------------------------------- +SAMPLE OUTPUT +perl .\OddOneOut.pl +Input: @words = (abc xyz tsu) +Output: 1 + +Input: @words = (rat cab dad) +Output: 3 + +Input: @words = (x y z) +Output: 0 +---------------------------------------- +=cut + + + |
