diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2022-04-20 10:57:05 +0200 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2022-04-20 10:57:05 +0200 |
| commit | 3a2868fb875e9a4a387f96b59d316e1ef777524e (patch) | |
| tree | 23c0eb477cc5704a4b840626b624e4c2120c1b88 | |
| parent | 8bc50a9ba8ab63a721cccb7dec77f2a65202b2b4 (diff) | |
| download | perlweeklychallenge-club-3a2868fb875e9a4a387f96b59d316e1ef777524e.tar.gz perlweeklychallenge-club-3a2868fb875e9a4a387f96b59d316e1ef777524e.tar.bz2 perlweeklychallenge-club-3a2868fb875e9a4a387f96b59d316e1ef777524e.zip | |
Task 1 done
| -rwxr-xr-x | challenge-161/luca-ferrari/raku/ch-1.p6 | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-161/luca-ferrari/raku/ch-1.p6 b/challenge-161/luca-ferrari/raku/ch-1.p6 new file mode 100755 index 0000000000..46550cc6d3 --- /dev/null +++ b/challenge-161/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,20 @@ +#!raku +# Perl Weekly Challenge 161 + + +sub MAIN( Str $dictionary-file-name? = '../../data/dictionary.txt' ) { + die "\nCannot find the dictionary [$dictionary-file-name]\n" if ! $dictionary-file-name || ! $dictionary-file-name.IO.f; + + # store the length and the list (array) of words for such length + my %abecedarian-words; + + for $dictionary-file-name.IO.lines -> $word { + # a word is abecedarian if the sorted letter composed word + # is equal to the word itself + %abecedarian-words{ $word.chars }.push: $word if ( $word.comb.sort.join ~~ $word ); + } + + # print the length and the list of words + "( $_ ):\n { %abecedarian-words{ $_ }.join( ',' ) }".say for %abecedarian-words.keys.sort; + +} |
