From e4094fbc0c23e39d793d94197b6b4474ec26cccc Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 25 Mar 2024 19:32:43 +0100 Subject: No, you were just stupid --- samples/aoc/2020/01/solve.bruijn | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'samples/aoc/2020') diff --git a/samples/aoc/2020/01/solve.bruijn b/samples/aoc/2020/01/solve.bruijn index 7e4c0d2..c3eb669 100644 --- a/samples/aoc/2020/01/solve.bruijn +++ b/samples/aoc/2020/01/solve.bruijn @@ -1,22 +1,9 @@ -# 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 +solve (find (sum → (eq? (+2020)))) → product -main [parts nums] - nums string→number <$> ~(<~>(lines 0)) - parts [(part1 (cross 0 0)) : (part2 (cross3 0 0 0))] +main trim → lines → (map string→number) → (φ (cons ⋔ solve) part1 part2) + part1 [[[~1 : {}0] <$> (drop ^0 1)] <++> (enumerate 0)] + part2 [[[[~2 : (~1 : {}0)] <$> (drop ^0 2)] <++> (enumerate (drop ^0 1))] <++> (enumerate 0)] -- cgit v1.2.3