2018d1 much faster (set vs. seq - TIL, again)

This commit is contained in:
Stefan Harmuth 2021-12-14 17:39:35 +01:00
parent 520791da78
commit b5569d4063

View File

@ -1,17 +1,18 @@
import std/intsets
import std/sequtils
import tools/aoc
let test: AOCDay = initAOCDay(1)
echo test.getInputInt().foldl(a + b)
var seen: seq[int]
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.add(freq)
seen.incl(freq)
else:
echo freq
found = true