aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-014/simon-proctor/perl6/ch-2.p626
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-014/simon-proctor/perl6/ch-2.p6 b/challenge-014/simon-proctor/perl6/ch-2.p6
new file mode 100644
index 0000000000..cad8992aa5
--- /dev/null
+++ b/challenge-014/simon-proctor/perl6/ch-2.p6
@@ -0,0 +1,26 @@
+#!/usr/bin/env
+
+use v6;
+
+subset FilePath of Str where *.IO.f;
+
+#| Look in the given dictionary for the longest word that can be made from the given dictionary
+sub MAIN(
+ FilePath :$dict = "/etc/dictionaries-common/words" #= Dictionary file to use. Defaults to "/etc/dictionaries-common/words"
+) {
+ my $states = bag( <AL AK AZ AR CA CO CT DE FL GA
+ HI ID IL IN IA KS KY LA ME MD
+ MA MI MN MS MO MT NE NV NH NJ
+ NM NY NC ND OH OK OR PA RI SC
+ SD TN TX UT VT VA WA WV WI WY> );
+ my $word = "";
+
+ for $dict.IO.words.grep( *.codes %% 2 ) -> $possible {
+ my $check = bag( $possible.uc.comb(/../ ) );
+ if $states (>=) $check && $possible.codes > $word.codes {
+ $word = $possible;
+ }
+ }
+
+ say $word;
+}