aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/aoc/2017/01/solve.bruijn
blob: 7dfef5a8b5df8b9c5a495e6f401a8ab4c4e5efb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
:import std/Combinator .
:import std/String .
:import std/Number .
:import std/Char C
:import std/Pair P

self [[(zip 0) ∘ (drop 1) ∘ cycle 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)