blob: dac0ed6758573822041131043312737db6acfe5f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)]
|