Part 2 for day 6 done as well

This commit is contained in:
Daniel Flanagan 2020-12-05 23:20:16 -06:00
parent e43a036788
commit ecff477d6e
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -1,8 +1,7 @@
import streams, sets, strutils, sequtils import streams, sets, strutils, sequtils
proc part1*(s: Stream): int = proc part1*(s: Stream): int =
# s.readAll().split("\n\n").mapIt(it.split("\n").foldl(a.union(b.toHashSet), initHashSet)).len
s.readAll().split("\n\n").mapIt(it.split("\n").foldl(a.union(b.toHashSet), initHashSet[char]()).len).foldl(a + b) s.readAll().split("\n\n").mapIt(it.split("\n").foldl(a.union(b.toHashSet), initHashSet[char]()).len).foldl(a + b)
proc part2*(s: Stream): int = proc part2*(s: Stream): int =
9 s.readAll().split("\n\n").mapIt(it.split("\n").filterIt(it != "").foldl(a.intersection(b.toHashSet), "abcdefghijklmnopqrstuvwxyz".toHashSet()).len).foldl(a + b)