aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/aoc/2015/02/solve.bruijn
diff options
context:
space:
mode:
Diffstat (limited to 'samples/aoc/2015/02/solve.bruijn')
-rw-r--r--samples/aoc/2015/02/solve.bruijn14
1 files changed, 14 insertions, 0 deletions
diff --git a/samples/aoc/2015/02/solve.bruijn b/samples/aoc/2015/02/solve.bruijn
new file mode 100644
index 0000000..96bd9e0
--- /dev/null
+++ b/samples/aoc/2015/02/solve.bruijn
@@ -0,0 +1,14 @@
+:import std/Combinator .
+:import std/String .
+:import std/Math .
+:import std/Char C
+
+parse (split-list-by (C.eq? 'x')) → (map string→number)
+
+main trim → lines → (map parse) → (φ cons part1 part2)
+ part1 foldl \(g add [φ add surface slack (^0 ⋅ ^(~0) : (^(~0) ⋅ ^(~(~0)) : {}(^(~(~0)) ⋅ ^0)))]) (+0)
+ surface foldl \(g add (mul (+2))) (+0)
+ slack lmin
+ part2 foldl \(g add (φ add ribbon bow)) (+0)
+ ribbon sort-asc → (take (+2)) → sum → (mul (+2))
+ bow product