2018d1 much faster (set vs. seq - TIL, again)
This commit is contained in:
parent
520791da78
commit
b5569d4063
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user