aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-239/wambash/raku/ch-1.raku17
-rw-r--r--challenge-239/wambash/raku/ch-2.raku21
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-239/wambash/raku/ch-1.raku b/challenge-239/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..4637ae6573
--- /dev/null
+++ b/challenge-239/wambash/raku/ch-1.raku
@@ -0,0 +1,17 @@
+#!/usr/bin/env raku
+
+sub same-string (\arr1,\arr2) {
+ arr1.join eq arr2.join
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is same-string(<ab c>, <a bc>), True;
+ is same-string(<ab c>, <ac b>), False;
+ is same-string(<ab cd e>, 'abcde'), True;
+ done-testing;
+}
+
+ multi MAIN (:@arr1,:@arr2) {
+ say same-string @arr1,@arr2
+}
diff --git a/challenge-239/wambash/raku/ch-2.raku b/challenge-239/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..e0a98281d6
--- /dev/null
+++ b/challenge-239/wambash/raku/ch-2.raku
@@ -0,0 +1,21 @@
+#!/usr/bin/env raku
+use v6.e.PREVIEW;
+
+sub consistent-strings (+str,:$allowed!) {
+ str
+ andthen .map: *.comb.Set
+ andthen .grep: { $_ ⊆ $allowed.comb.Set }\
+ andthen .elems
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is consistent-strings(<ad bd aaab baa badab>,:allowed('ab')),2;
+ is consistent-strings(<a b c ab ac bc abc>):allowed('abc'),7;
+ is consistent-strings(<cc acd b ba bac bad ac d>):allowed('cad'),4;
+ done-testing;
+}
+
+multi MAIN (+str,:$allowed!) {
+ say consistent-strings str,:$allowed
+}