aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Ransan <lucas@ransan.tk>2021-07-19 16:51:26 +0200
committerLucas Ransan <lucas@ransan.tk>2021-07-19 16:59:18 +0200
commit0429fdd2f5bfb40375aa5d92ad411cc54eb90d9a (patch)
tree29e015074a3dd5d1fb59dbc42246f54f213fc96e
parenta119923d7c654f6494e995493b87c69a44276eed (diff)
downloadperlweeklychallenge-club-0429fdd2f5bfb40375aa5d92ad411cc54eb90d9a.tar.gz
perlweeklychallenge-club-0429fdd2f5bfb40375aa5d92ad411cc54eb90d9a.tar.bz2
perlweeklychallenge-club-0429fdd2f5bfb40375aa5d92ad411cc54eb90d9a.zip
Raku week 122 task 2
-rwxr-xr-xchallenge-122/luc65r/raku/ch-2.raku21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-122/luc65r/raku/ch-2.raku b/challenge-122/luc65r/raku/ch-2.raku
new file mode 100755
index 0000000000..53d91e2718
--- /dev/null
+++ b/challenge-122/luc65r/raku/ch-2.raku
@@ -0,0 +1,21 @@
+#!/usr/bin/env raku
+
+use experimental :cached;
+
+proto score(UInt:D --> Seq) is cached {*}
+
+multi score(0) { [], }
+
+multi score($n) {
+ gather for 1..3 -> $i {
+ with try score($n - $i) -> @s {
+ for @s {
+ take [$i, |@_];
+ }
+ }
+ }
+}
+
+sub MAIN(UInt $n) {
+ .join(' ').say for score $n;
+}