From 9ef10406c067d0a0532d609212a94519af402b87 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 7 Mar 2023 00:19:48 +0100 Subject: Added a few advent of code solutions --- samples/aoc/2019/01/input | 4 ++++ samples/aoc/2019/01/solve.bruijn | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 samples/aoc/2019/01/input create mode 100644 samples/aoc/2019/01/solve.bruijn (limited to 'samples/aoc/2019/01') 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)] -- cgit v1.2.3