From b5569d4063ea6212c1abf7740a1e14d331d1c9e2 Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Tue, 14 Dec 2021 17:39:35 +0100 Subject: [PATCH] 2018d1 much faster (set vs. seq - TIL, again) --- aoc2018.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aoc2018.nim b/aoc2018.nim index ca7239a..7790a81 100644 --- a/aoc2018.nim +++ b/aoc2018.nim @@ -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