aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-06-10 09:19:25 +0100
committerGitHub <noreply@github.com>2025-06-10 09:19:25 +0100
commite4713f7b26c48af9496dcd0a817ea870f5cc49e6 (patch)
treeeab86d56941ecf7e9d316207d64aaef8bebefcea
parenta3969127afb2acd2c6834aba0cacc71b88ee6e17 (diff)
parent7adf91401803cfd07f0d055c0b3dd0c94649542e (diff)
downloadperlweeklychallenge-club-e4713f7b26c48af9496dcd0a817ea870f5cc49e6.tar.gz
perlweeklychallenge-club-e4713f7b26c48af9496dcd0a817ea870f5cc49e6.tar.bz2
perlweeklychallenge-club-e4713f7b26c48af9496dcd0a817ea870f5cc49e6.zip
Merge pull request #12153 from ash/ash-325
Solutions Week 325 by @ash in Raku
-rw-r--r--challenge-325/ash/raku/ch-1.raku17
-rw-r--r--challenge-325/ash/raku/ch-2.raku13
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-325/ash/raku/ch-1.raku b/challenge-325/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..bb4870b7ad
--- /dev/null
+++ b/challenge-325/ash/raku/ch-1.raku
@@ -0,0 +1,17 @@
+
+# Task 1 of the Weekly Challenge 325
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-325
+
+say solve 0, 1, 1, 0, 1, 1, 1; # 3
+say solve 0, 0, 0, 0; # 0
+say solve 1, 0, 1, 0, 1, 1; # 2
+
+
+sub solve(*@data) {
+ (
+ (
+ @data.join ~~ m:g/(1+)/
+ )>>.chars
+ || 0
+ ).max
+}
diff --git a/challenge-325/ash/raku/ch-2.raku b/challenge-325/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..c3cb4d9ee8
--- /dev/null
+++ b/challenge-325/ash/raku/ch-2.raku
@@ -0,0 +1,13 @@
+
+# Task 2 of the Weekly Challenge 325
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-325
+
+say solve 8, 4, 6, 2, 3; # 4, 2, 4, 2, 3
+say solve 1, 2, 3, 4, 5; # 1, 2, 3, 4, 5
+say solve 7, 1, 1, 5; # 6, 0, 1, 5
+
+sub solve(*@data) {
+ @data.kv.map: -> $index, $price {
+ $price - ((@data[$index + 1 .. *].first: * <= $price) // 0);
+ }
+}