From c86ef829869f300148c60b34e13ff8ea528d241d Mon Sep 17 00:00:00 2001 From: Joelle Maslak Date: Wed, 17 Apr 2019 10:18:53 -0500 Subject: Add solution for challenge problem 2 --- challenge-004/joelle-maslak/perl6/ch-2.pl6 | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 challenge-004/joelle-maslak/perl6/ch-2.pl6 diff --git a/challenge-004/joelle-maslak/perl6/ch-2.pl6 b/challenge-004/joelle-maslak/perl6/ch-2.pl6 new file mode 100755 index 0000000000..a8175def20 --- /dev/null +++ b/challenge-004/joelle-maslak/perl6/ch-2.pl6 @@ -0,0 +1,38 @@ +#!/usr/bin/env perl6 +use v6; + +# To call this application: +# +# perl6 ch-2.p6 +# +# If you want to use /usr/share/dict/words as the word list, you can +# omit the filename. +# +# Example: +# +# perl6 ch-2.p6 aet +# +# which is equivilent to: +# +# perl6 ch-2.p6 eat /usr/share/dict/words +# +# With my Unix dictionary (English), it returns ate, eat, eta, and tea. +# + +sub MAIN(Str:D $letters, Str:D $filename = '/usr/share/dict/words') { + my $matchbag = Bag.new($letters.comb); + my SetHash $dedupe = SetHash.new; # To store matches we gave back + + for $filename.IO.lines -> $word { + my $fcword = $word.fc; + + my $bag = Bag.new($fcword.comb); + + if $bag ~~ $matchbag { + next if $fcword ∈ $dedupe; + $dedupe{$fcword}++; + say $fcword if $bag ~~ $matchbag; + } + } +} + -- cgit From 9f4d19d7eee46cdf9064c2737724ac8d927a237d Mon Sep 17 00:00:00 2001 From: Joelle Maslak Date: Wed, 17 Apr 2019 10:22:31 -0500 Subject: Rename to p6 --- challenge-004/joelle-maslak/perl6/ch-2.p6 | 38 ++++++++++++++++++++++++++++++ challenge-004/joelle-maslak/perl6/ch-2.pl6 | 38 ------------------------------ 2 files changed, 38 insertions(+), 38 deletions(-) create mode 100755 challenge-004/joelle-maslak/perl6/ch-2.p6 delete mode 100755 challenge-004/joelle-maslak/perl6/ch-2.pl6 diff --git a/challenge-004/joelle-maslak/perl6/ch-2.p6 b/challenge-004/joelle-maslak/perl6/ch-2.p6 new file mode 100755 index 0000000000..a8175def20 --- /dev/null +++ b/challenge-004/joelle-maslak/perl6/ch-2.p6 @@ -0,0 +1,38 @@ +#!/usr/bin/env perl6 +use v6; + +# To call this application: +# +# perl6 ch-2.p6 +# +# If you want to use /usr/share/dict/words as the word list, you can +# omit the filename. +# +# Example: +# +# perl6 ch-2.p6 aet +# +# which is equivilent to: +# +# perl6 ch-2.p6 eat /usr/share/dict/words +# +# With my Unix dictionary (English), it returns ate, eat, eta, and tea. +# + +sub MAIN(Str:D $letters, Str:D $filename = '/usr/share/dict/words') { + my $matchbag = Bag.new($letters.comb); + my SetHash $dedupe = SetHash.new; # To store matches we gave back + + for $filename.IO.lines -> $word { + my $fcword = $word.fc; + + my $bag = Bag.new($fcword.comb); + + if $bag ~~ $matchbag { + next if $fcword ∈ $dedupe; + $dedupe{$fcword}++; + say $fcword if $bag ~~ $matchbag; + } + } +} + diff --git a/challenge-004/joelle-maslak/perl6/ch-2.pl6 b/challenge-004/joelle-maslak/perl6/ch-2.pl6 deleted file mode 100755 index a8175def20..0000000000 --- a/challenge-004/joelle-maslak/perl6/ch-2.pl6 +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env perl6 -use v6; - -# To call this application: -# -# perl6 ch-2.p6 -# -# If you want to use /usr/share/dict/words as the word list, you can -# omit the filename. -# -# Example: -# -# perl6 ch-2.p6 aet -# -# which is equivilent to: -# -# perl6 ch-2.p6 eat /usr/share/dict/words -# -# With my Unix dictionary (English), it returns ate, eat, eta, and tea. -# - -sub MAIN(Str:D $letters, Str:D $filename = '/usr/share/dict/words') { - my $matchbag = Bag.new($letters.comb); - my SetHash $dedupe = SetHash.new; # To store matches we gave back - - for $filename.IO.lines -> $word { - my $fcword = $word.fc; - - my $bag = Bag.new($fcword.comb); - - if $bag ~~ $matchbag { - next if $fcword ∈ $dedupe; - $dedupe{$fcword}++; - say $fcword if $bag ~~ $matchbag; - } - } -} - -- cgit