From 11b942c9ad3142b9661f213588fdb03b0405f08b Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 9 Apr 2024 19:36:50 +0200 Subject: Added test for AOC samples (although 2018 is actually broken) --- samples/aoc/2017/01/input | 2 +- samples/aoc/2017/01/output.check | 1 + samples/aoc/2017/01/solve.bruijn | 21 +++++---------------- 3 files changed, 7 insertions(+), 17 deletions(-) create mode 100644 samples/aoc/2017/01/output.check (limited to 'samples/aoc/2017/01') diff --git a/samples/aoc/2017/01/input b/samples/aoc/2017/01/input index 8f237ab..1d95b9e 100644 --- a/samples/aoc/2017/01/input +++ b/samples/aoc/2017/01/input @@ -1 +1 @@ -12131415 +91212129 diff --git a/samples/aoc/2017/01/output.check b/samples/aoc/2017/01/output.check new file mode 100644 index 0000000..a46999a --- /dev/null +++ b/samples/aoc/2017/01/output.check @@ -0,0 +1 @@ +?> <9t : 6t> diff --git a/samples/aoc/2017/01/solve.bruijn b/samples/aoc/2017/01/solve.bruijn index db29872..7dfef5a 100644 --- a/samples/aoc/2017/01/solve.bruijn +++ b/samples/aoc/2017/01/solve.bruijn @@ -4,20 +4,9 @@ :import std/Char C :import std/Pair P -self [[((zip 0) ∘ (drop 1) ∘ cycle) 0]] ⧗ Number → (List Number) → (List (Pair Number Number)) +self [[(zip 0) ∘ (drop 1) ∘ cycle 0]] -part1 sum ∘ eqs ∘ pairs - sum foldl [[^0 + 1]] (+0) - eqs filter (P.uncurry …=?…) - pairs self (+1) - -part2 [(sum ∘ eqs ∘ pairs) 0] - sum foldl [[^0 + 1]] (+0) - eqs filter (P.uncurry …=?…) - pairs self /²(length 0) - -:test (part1 ((+1) : ((+1) : ((+2) : {}(+2))))) ((+3)) - -main [parts nums] - nums C.char→number <$> ^(lines 0) - parts [(part1 0) : (part2 0)] +main [φ (cons ⋔ solve) part1 part2 (C.char→number <$> (trim 0))] + solve (filter (P.uncurry eq?)) → (foldl \(g add head) (+0)) + part1 self (+1) + part2 self /²(length 0) -- cgit v1.2.3