advent-of-code/2021/one.nim

10 lines
339 B
Nim
Raw Normal View History

2021-12-07 23:05:47 -06:00
import ./common, std/[sequtils, sugar]
2021-12-01 16:41:27 -06:00
proc countDepthIncreases(inputs: seq[int], dist=1): int =
2021-12-07 23:05:47 -06:00
(dist..<inputs.len()).toSeq().foldl(a + int(inputs[b] > inputs[b-dist]), 0)
2021-12-01 16:41:27 -06:00
2021-12-07 23:05:47 -06:00
doDay(1, (n) => n.loadInput().toInts(),
(n) => n.countDepthIncreases(),
(n) => n.countDepthIncreases(3),
@[199,200,208,210,200,207,240,269,260,263], 7, 5)