diff options
| author | Rob4t <robertgratza@web.de> | 2019-04-22 14:39:05 +0200 |
|---|---|---|
| committer | Rob4t <robertgratza@web.de> | 2019-04-22 14:39:05 +0200 |
| commit | dd93f741588af128748c55bf327bf2ed9bf75b7c (patch) | |
| tree | 9fd759b10eb8cd9f001b5cf9301c08c6d262c633 /challenge-005/rob4t | |
| parent | 863762cb5e270a478f349163b1d466398290157c (diff) | |
| download | perlweeklychallenge-club-dd93f741588af128748c55bf327bf2ed9bf75b7c.tar.gz perlweeklychallenge-club-dd93f741588af128748c55bf327bf2ed9bf75b7c.tar.bz2 perlweeklychallenge-club-dd93f741588af128748c55bf327bf2ed9bf75b7c.zip | |
solution for challenge 005
Diffstat (limited to 'challenge-005/rob4t')
| -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..5e12e50898 --- /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 = '/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); + } +} |
