From a96de55fbe46daa3a1bfd7f38bf4d6c37959d325 Mon Sep 17 00:00:00 2001 From: Jan Krňávek Date: Sun, 8 Jun 2025 10:34:54 +0200 Subject: solutions week 324 --- challenge-324/wambash/raku/ch-1.raku | 17 +++++++++++++++++ challenge-324/wambash/raku/ch-2.raku | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 challenge-324/wambash/raku/ch-1.raku create mode 100644 challenge-324/wambash/raku/ch-2.raku 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; +} -- cgit