aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/aoc/2018/01/solve.bruijn
blob: 0fd04489e204b0d4d2669ca37e8fc76e5122a190 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
:import std/Combinator .
:import std/String .
:import std/Math .
:import std/Set S

part1 ∑‣ ⧗ (List FrequencyDiff) → Frequency

part2 z [[[[rec]]]] S.empty (+0) ⧗ (List FrequencyDiff) → Frequency
	rec (S.has? 1 2) case-end case-cont
		case-cont 3 (S.add 1 2) (1 + ^0) ~0
		case-end 1

main [parts nums]
	nums string→signed-number <$> (init (lines 0))
	parts [(part1 0) : (part2 (cycle 0))]