aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-06-08 22:55:39 +0100
committerGitHub <noreply@github.com>2025-06-08 22:55:39 +0100
commit01b02298df3aab87c69198d274980ad5221cd9af (patch)
tree756b864324b3e876d66689a5f00cd37b1eafa207
parentbf2a91a2d96be171072ec3eaf578ba2a84d60796 (diff)
parenta96de55fbe46daa3a1bfd7f38bf4d6c37959d325 (diff)
downloadperlweeklychallenge-club-01b02298df3aab87c69198d274980ad5221cd9af.tar.gz
perlweeklychallenge-club-01b02298df3aab87c69198d274980ad5221cd9af.tar.bz2
perlweeklychallenge-club-01b02298df3aab87c69198d274980ad5221cd9af.zip
Merge pull request #12141 from wambash/challenge-week-324
solutions week 324
-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;
+}