diff options
Diffstat (limited to 'samples/aoc/2018')
-rw-r--r-- | samples/aoc/2018/01/input | 5 | ||||
-rw-r--r-- | samples/aoc/2018/01/solve.bruijn | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/samples/aoc/2018/01/input b/samples/aoc/2018/01/input new file mode 100644 index 0000000..78cd296 --- /dev/null +++ b/samples/aoc/2018/01/input @@ -0,0 +1,5 @@ ++7 ++7 +-2 +-7 +-4 diff --git a/samples/aoc/2018/01/solve.bruijn b/samples/aoc/2018/01/solve.bruijn new file mode 100644 index 0000000..cb47892 --- /dev/null +++ b/samples/aoc/2018/01/solve.bruijn @@ -0,0 +1,15 @@ +:import std/Combinator . +:import std/String . +:import std/Math . +:import std/Set S + +part1 ∑‣ ⧗ (List FrequencyDiff) → Frequency + +part2 z [[[[rec]]]] S.empty (+0) ⧗ (List FrequencyDiff) → Frequency + rec (S.has? 1 2) case-end case-cont + case-cont 3 (S.add 1 2) (1 + ^0) ~0 + case-end 1 + +main [parts nums] + nums signed-number! <$> (init (lines 0)) + parts [(part1 0) : (part2 (cycle 0))] |