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/2020 | |
parent | 61b749cf19b30a307ef537f989e5509c3c4aa17f (diff) |
Added a few advent of code solutions
Diffstat (limited to 'samples/aoc/2020')
-rw-r--r-- | samples/aoc/2020/01/input | 6 | ||||
-rw-r--r-- | samples/aoc/2020/01/solve.bruijn | 22 |
2 files changed, 28 insertions, 0 deletions
diff --git a/samples/aoc/2020/01/input b/samples/aoc/2020/01/input new file mode 100644 index 0000000..e3fb011 --- /dev/null +++ b/samples/aoc/2020/01/input @@ -0,0 +1,6 @@ +1721 +979 +366 +299 +675 +1456 diff --git a/samples/aoc/2020/01/solve.bruijn b/samples/aoc/2020/01/solve.bruijn new file mode 100644 index 0000000..39bfcbc --- /dev/null +++ b/samples/aoc/2020/01/solve.bruijn @@ -0,0 +1,22 @@ +# TODO: While this obviously isn't the most performant solution, it should still +# be a lot faster than it currently is. I think there's some problem with +# underlying strictness/laziness + +:import std/Combinator . +:import std/String . +:import std/Math . +:import std/Pair P + +part1 z [[rec]] + rec ((P.uncurry …+… ^0) =? (+2020)) case-done case-cont + case-done P.uncurry …⋅… ^0 + case-cont 1 ~0 + +part2 z [[rec]] + rec (∑(^0) =? (+2020)) case-done case-cont + case-done ∏(^0) + case-cont 1 ~0 + +main [parts nums] + nums number! <$> ~(<~>(lines 0)) + parts [(part1 (cross 0 0)) : (part2 (cross3 0 0 0))] |