aoc2018/aoc2018.nim
2021-12-14 22:15:50 +01:00

20 lines
399 B
Nim

import std/intsets
import std/sequtils
import tools/aoc
let test: AOCDay = initAOCDay(1)
printSolution(1, 1, test.getInputInt().foldl(a + b))
var seen: IntSet = initIntSet()
var freq: int = 0
var found: bool = false
while not found:
for x in test.getInputInt():
freq += x
if freq notin seen:
seen.incl(freq)
else:
printSolution(1, 2, freq)
found = true
break