aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/aoc/2022/01/solve.bruijn
diff options
context:
space:
mode:
Diffstat (limited to 'samples/aoc/2022/01/solve.bruijn')
-rw-r--r--samples/aoc/2022/01/solve.bruijn10
1 files changed, 4 insertions, 6 deletions
diff --git a/samples/aoc/2022/01/solve.bruijn b/samples/aoc/2022/01/solve.bruijn
index 7b2eaf6..e213e85 100644
--- a/samples/aoc/2022/01/solve.bruijn
+++ b/samples/aoc/2022/01/solve.bruijn
@@ -1,9 +1,7 @@
+:import std/Combinator .
:import std/Math .
:import std/String .
-main [answer]
- numbers string→number <$> (lines 0)
- parts split-list-by =?‣ numbers
- sums sum <$> parts
- answer build (sort-desc sums)
- build [^0 : ∑(take (+3) 0)]
+main blocks → (map (map string→number)) → (map sum) → sort-desc → res
+ res [^0 : (^0 + ^(~0) + ^(~(~0)))]
+ blocks [split-list-by (eq? "\n") (lines 0)]