aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Ransan <lucas@ransan.tk>2021-07-24 23:06:01 +0200
committerLucas Ransan <lucas@ransan.tk>2021-07-24 23:12:08 +0200
commit7d1fea4b17eacff9b0d8c3ef7a8f404e0565b1be (patch)
tree16fde3c05153dae8889884825b8fc7b96066b0d3
parenta97eb2b447dda53bae13f57bf98003f5b8f5d934 (diff)
downloadperlweeklychallenge-club-7d1fea4b17eacff9b0d8c3ef7a8f404e0565b1be.tar.gz
perlweeklychallenge-club-7d1fea4b17eacff9b0d8c3ef7a8f404e0565b1be.tar.bz2
perlweeklychallenge-club-7d1fea4b17eacff9b0d8c3ef7a8f404e0565b1be.zip
Coconut week 122 task 2
-rwxr-xr-xchallenge-122/luc65r/coconut/ch-2.coco17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-122/luc65r/coconut/ch-2.coco b/challenge-122/luc65r/coconut/ch-2.coco
new file mode 100755
index 0000000000..081ef09edf
--- /dev/null
+++ b/challenge-122/luc65r/coconut/ch-2.coco
@@ -0,0 +1,17 @@
+#!/usr/bin/env -S coconut-run --strict
+
+import sys
+
+flatten = reduce $ (::)
+
+def scores(0) = [[]]
+
+@addpattern(scores)
+def scores(n) =
+ range(1, 4) ↦ filter $ ((≥) $ n) ↦ map $ (
+ i → scores(n − i) ↦ map $ (→ [i] + _)
+ ) ↦ flatten
+
+sys.argv[1] ↦ int ↦ scores ↦ map $ (
+ l → ' '.join(map(str, l))
+) ↦ '\n'.join ↦ print