advent-of-code/2020/src/day10.nim

17 lines
316 B
Nim
Raw Normal View History

2020-12-10 01:08:23 -06:00
import streams, input_helpers, algorithm, sequtils
2020-12-09 09:44:13 -06:00
proc part1*(s: Stream): int =
2020-12-10 01:08:23 -06:00
var d1 = 0
var d3 = 1
var nums = @[0].concat(toSeq(s.asInts).sorted)
for i in 1..<nums.len:
case nums[i] - nums[i-1]:
of 1: inc d1
of 3: inc d3
else: discard
d1 * d3
2020-12-09 09:44:13 -06:00
proc part2*(s: Stream): int =
0