aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-204/mark-anderson/raku/ch-1.raku13
-rw-r--r--challenge-204/mark-anderson/raku/ch-2.raku13
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-204/mark-anderson/raku/ch-1.raku b/challenge-204/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..e7c4a2f3db
--- /dev/null
+++ b/challenge-204/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+use Test;
+
+ok monotonic-array(1,2,2,3);
+nok monotonic-array(1,3,2);
+ok monotonic-array(6,5,5,4);
+
+sub monotonic-array(*@a)
+{
+ return 1 if [<=] @a;
+ return 1 if [>=] @a;
+ return 0
+}
diff --git a/challenge-204/mark-anderson/raku/ch-2.raku b/challenge-204/mark-anderson/raku/ch-2.raku
new file mode 100644
index 0000000000..da3853abe5
--- /dev/null
+++ b/challenge-204/mark-anderson/raku/ch-2.raku
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+use Test;
+
+is-deeply reshape-matrix(1, 4, [[1,2], [3,4]]), [[1,2,3,4],];
+is-deeply reshape-matrix(3, 2, [[1,2,3], [4,5,6]]), [[1,2],[3,4],[5,6]];
+nok reshape-matrix(3, 2, [[1,2]]);
+
+sub reshape-matrix($r, $c, @m)
+{
+ @m .= map(*.Slip);
+ return 0 if $r * $c !== @m;
+ @m.rotor($c).map(*.Array).Array
+}