aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Shitov <ash@Andreys-iMac.local>2025-09-08 08:53:30 +0300
committerAndrey Shitov <ash@Andreys-iMac.local>2025-09-08 08:53:30 +0300
commitfe39fe9342c2b9ce025d160c4fdba5af58db55f9 (patch)
tree7352a1adc2fb396d86a1a0be64dd3797952cb58a
parent12d9b7370121f12b601562856772ed3c03f7bb94 (diff)
downloadperlweeklychallenge-club-fe39fe9342c2b9ce025d160c4fdba5af58db55f9.tar.gz
perlweeklychallenge-club-fe39fe9342c2b9ce025d160c4fdba5af58db55f9.tar.bz2
perlweeklychallenge-club-fe39fe9342c2b9ce025d160c4fdba5af58db55f9.zip
Week 338, solutions in Raku by @ash
-rw-r--r--challenge-338/ash/raku/ch-1.raku26
-rw-r--r--challenge-338/ash/raku/ch-2.raku12
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-338/ash/raku/ch-1.raku b/challenge-338/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..7c1d747559
--- /dev/null
+++ b/challenge-338/ash/raku/ch-1.raku
@@ -0,0 +1,26 @@
+# Task 1 of The Weekly Challenge 338
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-338/#TASK1
+
+say max-sum([[4, 4, 4, 4],
+ [10, 0, 0, 0],
+ [2, 2, 2, 9]]); # 16
+
+say max-sum([[1, 5],
+ [7, 3],
+ [3, 5]]); # 10
+
+say max-sum([[1, 2, 3],
+ [3, 2, 1]]); # 6
+
+say max-sum([[2, 8, 7],
+ [7, 1, 3],
+ [1, 9, 5]]); # 17
+
+say max-sum([[10, 20, 30],
+ [5, 5, 5],
+ [0, 100, 0],
+ [25, 25, 25]]); # 100
+
+sub max-sum(*@matrix) {
+ @matrix>>.sum.max
+}
diff --git a/challenge-338/ash/raku/ch-2.raku b/challenge-338/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..5cbb72f41b
--- /dev/null
+++ b/challenge-338/ash/raku/ch-2.raku
@@ -0,0 +1,12 @@
+# Task 2 of The Weekly Challenge 338
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-338/#TASK2
+
+say max-distance([4, 5, 7], [9, 1, 3, 4]); # 6
+say max-distance([2, 3, 5, 4], [3, 2, 5, 5, 8, 7]); # 6
+say max-distance([2, 1, 11, 3], [2, 5, 10, 2]); # 9
+say max-distance([1, 2, 3], [3, 2, 1]); # 2
+say max-distance([1, 0, 2, 3], [5, 0]); # 5
+
+sub max-distance(@a, @b) {
+ ((@a X @b).map: {abs([-] $_)}).max
+}