diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-04-23 23:18:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-23 23:18:57 +0100 |
| commit | cad22cd69b907f5f06e7fb820498ec0e22414dc5 (patch) | |
| tree | c5e301d5d429dfebbe9c56741d0d0040da6aaabf /challenge-161 | |
| parent | 09856afcbf621980d5905f48911447773ed48079 (diff) | |
| parent | 0f3d9a6af4858fb586771cd1d7cd66cc6bc68407 (diff) | |
| download | perlweeklychallenge-club-cad22cd69b907f5f06e7fb820498ec0e22414dc5.tar.gz perlweeklychallenge-club-cad22cd69b907f5f06e7fb820498ec0e22414dc5.tar.bz2 perlweeklychallenge-club-cad22cd69b907f5f06e7fb820498ec0e22414dc5.zip | |
Merge pull request #5985 from simbabque/master
I forgot the sorting!
Diffstat (limited to 'challenge-161')
| -rw-r--r-- | challenge-161/julien-fiegehenn/perl/ch-1.pl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/challenge-161/julien-fiegehenn/perl/ch-1.pl b/challenge-161/julien-fiegehenn/perl/ch-1.pl index ce487004a6..d6201f6e06 100644 --- a/challenge-161/julien-fiegehenn/perl/ch-1.pl +++ b/challenge-161/julien-fiegehenn/perl/ch-1.pl @@ -8,12 +8,17 @@ my @dictionary = do { open my $fh, '<', 'data/dictionary.txt' or die $!; <$fh>; }; chomp @dictionary; +my %words; WORD: for my $word (@dictionary) { + next if length $word < 2; # say $word if join(q{}, sort split //, $word) eq $word; ## this seems like the obvious solution my @letters = split //, $word; for my $i (0 .. $#letters - 1) { next WORD unless ord($letters[$i]) <= ord($letters[$i + 1]); } - say $word; + $words{$word} = length $word; } + +# hi, below empty deers cry most knotty eggs no apt gin. +say for sort { $words{$b} <=> $words{$a} } keys %words;
\ No newline at end of file |
