diff options
author | Marvin Borner | 2023-03-07 00:19:48 +0100 |
---|---|---|
committer | Marvin Borner | 2023-03-07 00:19:48 +0100 |
commit | 9ef10406c067d0a0532d609212a94519af402b87 (patch) | |
tree | 8d30448311ec43678873050ff7654d7f6c348ec8 /samples/aoc/2019 | |
parent | 61b749cf19b30a307ef537f989e5509c3c4aa17f (diff) |
Added a few advent of code solutions
Diffstat (limited to 'samples/aoc/2019')
-rw-r--r-- | samples/aoc/2019/01/input | 4 | ||||
-rw-r--r-- | samples/aoc/2019/01/solve.bruijn | 27 |
2 files changed, 31 insertions, 0 deletions
diff --git a/samples/aoc/2019/01/input b/samples/aoc/2019/01/input new file mode 100644 index 0000000..f620e23 --- /dev/null +++ b/samples/aoc/2019/01/input @@ -0,0 +1,4 @@ +12 +14 +1969 +100756 diff --git a/samples/aoc/2019/01/solve.bruijn b/samples/aoc/2019/01/solve.bruijn new file mode 100644 index 0000000..518d198 --- /dev/null +++ b/samples/aoc/2019/01/solve.bruijn @@ -0,0 +1,27 @@ +:import std/Combinator . +:import std/Logic . +:import std/String . +:import std/Math . + +fuel [/³*0 - (+2)] ⧗ Mass → Fuel + +:test ((fuel (+12)) =? (+2)) (true) +:test ((fuel (+14)) =? (+2)) (true) +:test ((fuel (+1969)) =? (+654)) (true) +:test ((fuel (+100756)) =? (+33583)) (true) + +fuelfuel z [[rec]] ⧗ Mass → Fuel + rec go (fuel 0) + go [>?0 (0 + (2 0)) (+0)] + +:test ((fuelfuel (+14)) =? (+2)) (true) +:test ((fuelfuel (+1969)) =? (+966)) (true) +:test ((fuelfuel (+100756)) =? (+50346)) (true) + +part1 ∑‣ ∘ (map fuel) ⧗ (List Mass) → Fuel + +part2 ∑‣ ∘ (map fuelfuel) ⧗ (List Mass) → Fuel + +main [parts nums] + nums number! <$> ~(<~>(lines 0)) + parts [(part1 0) : (part2 0)] |