adventofcode2021/day01/part1.nim

22 lines
380 B
Nim

import strutils
proc countIncreases(): uint =
var
line = ""
prevDepth = high(uint)
while readLine(stdin, line):
if line.len() > 0:
let depth = parseUint(line)
if depth > prevDepth:
result.inc()
prevDepth = depth
proc main(): int =
try:
echo countIncreases()
except ValueError:
result = -1
when isMainModule:
quit(main())