aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-324/wambash/raku/ch-1.raku17
-rw-r--r--challenge-324/wambash/raku/ch-2.raku19
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-324/wambash/raku/ch-1.raku b/challenge-324/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..b599494ee2
--- /dev/null
+++ b/challenge-324/wambash/raku/ch-1.raku
@@ -0,0 +1,17 @@
+sub two-d-array (+ints,:$row,:$col) {
+ ints
+ andthen .batch: $col
+ andthen .head: $row
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is-deeply two-d-array(^4+1):2row:2col, ((1,2),(3,4));
+ is-deeply two-d-array(^3+1):1row:3col, ((1,2,3),);
+ is-deeply two-d-array(^4+1):4row:1col, ((1,),(2,),(3,),(4,));
+ done-testing;
+}
+
+multi MAIN (+ints,:$row,:$col) {
+ say two-d-array ints,:$row,:$col;
+}
diff --git a/challenge-324/wambash/raku/ch-2.raku b/challenge-324/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..2332236704
--- /dev/null
+++ b/challenge-324/wambash/raku/ch-2.raku
@@ -0,0 +1,19 @@
+sub total-xor (+ints) {
+ ints
+ andthen .combinations: 1..*
+ andthen .map: {[+^] $_}\
+ andthen .sum
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is total-xor(1,3), 6;
+ is total-xor(5,1,6), 28;
+ is total-xor(3..8), 480;
+ is total-xor(^11), 15360;
+ done-testing;
+}
+
+multi MAIN (+ints) {
+ say total-xor ints;
+}