aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-253/mark-anderson/raku/ch-1.raku13
-rw-r--r--challenge-253/mark-anderson/raku/ch-2.raku33
2 files changed, 46 insertions, 0 deletions
diff --git a/challenge-253/mark-anderson/raku/ch-1.raku b/challenge-253/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..0b4b73fcde
--- /dev/null
+++ b/challenge-253/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+use Test;
+
+is-deeply split-strings(<one.two.three four.five six>, '.'),
+ <one two three four five six>;
+
+is-deeply split-strings(<$perl$$ $$raku$>, '$'),
+ <perl raku>;
+
+sub split-strings(@a, $separator)
+{
+ flat @a>>.split($separator, :skip-empty)
+}
diff --git a/challenge-253/mark-anderson/raku/ch-2.raku b/challenge-253/mark-anderson/raku/ch-2.raku
new file mode 100644
index 0000000000..1a581b0901
--- /dev/null
+++ b/challenge-253/mark-anderson/raku/ch-2.raku
@@ -0,0 +1,33 @@
+#!/usr/bin/env raku
+use Test;
+
+is-deeply weakest-rows([
+ [1, 1, 0, 0, 0],
+ [1, 1, 1, 1, 0],
+ [1, 0, 0, 0, 0],
+ [1, 1, 0, 0, 0],
+ [1, 1, 1, 1, 1]
+ ]),
+ (2, 0, 3, 1, 4);
+
+is-deeply weakest-rows([
+ [1, 0, 0, 0],
+ [1, 1, 1, 1],
+ [1, 0, 0, 0],
+ [1, 0, 0, 0]
+ ]),
+ (0, 2, 3, 1);
+
+is-deeply weakest-rows([
+ [1, 1, 0, 0, 0],
+ [1, 1, 1, 1, 0],
+ [0, 0, 0, 0, 0],
+ [1, 1, 0, 0, 0],
+ [1, 1, 1, 1, 1]
+ ]),
+ (2, 0, 3, 1, 4);
+
+sub weakest-rows($m)
+{
+ $m.map({ .first(0, :k) // ∞ }).antipairs.sort>>.value
+}