diff options
| -rw-r--r-- | challenge-005/rob4t/perl6/ch-1.p6 | 16 | ||||
| -rw-r--r-- | challenge-005/rob4t/perl6/ch-2.p6 | 11 |
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-005/rob4t/perl6/ch-1.p6 b/challenge-005/rob4t/perl6/ch-1.p6 new file mode 100644 index 0000000000..d4f5295fbe --- /dev/null +++ b/challenge-005/rob4t/perl6/ch-1.p6 @@ -0,0 +1,16 @@ +#!/usr/bin/env perl6 +use v6; + +sub MAIN(Str $word, Str $file where *.IO.r = '/usr/share/dict/words') { + my $word_bag = $word.lc.comb.Bag; + + my @found_words = $file.IO.lines.grep: { + # not the same word + .lc ne $word.lc + and + # look for words AND phrases + .lc.words.map({.comb}).flat.Bag eqv $word_bag + }; + + .say for @found_words; +} diff --git a/challenge-005/rob4t/perl6/ch-2.p6 b/challenge-005/rob4t/perl6/ch-2.p6 new file mode 100644 index 0000000000..d705130729 --- /dev/null +++ b/challenge-005/rob4t/perl6/ch-2.p6 @@ -0,0 +1,11 @@ +#!/usr/bin/env perl6 +use v6; + +sub MAIN(Str $file where *.IO.r = '/usr/share/dict/words' ) { + my %a is Bag = $file.IO.lines.map({.words.map({.comb}).flat.Bag}); + + my $max_val = %a.values.max; + for %a.pairs.grep: *.value == $max_val { + say join(": ", .value, .key.kxxv.sort.join); + } +} |
