diff options
Diffstat (limited to 'samples/aoc/2017/01/solve.bruijn')
-rw-r--r-- | samples/aoc/2017/01/solve.bruijn | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/samples/aoc/2017/01/solve.bruijn b/samples/aoc/2017/01/solve.bruijn new file mode 100644 index 0000000..dac0ed6 --- /dev/null +++ b/samples/aoc/2017/01/solve.bruijn @@ -0,0 +1,23 @@ +:import std/Combinator . +:import std/String . +:import std/Number . +:import std/Char C +:import std/Pair P + +self [[((zip 0) ∘ (drop 1) ∘ cycle) 0]] ⧗ Number → (List Number) → (List (Pair Number Number)) + +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.number! <$> ^(lines 0) + parts [(part1 0) : (part2 0)] |