This commit is contained in:
Daniel Flanagan 2021-12-08 11:35:50 -06:00
parent e9e1909c88
commit 607cb130a3
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -3,7 +3,7 @@ import ./common, std/[strutils, sequtils, strformat, sugar, sets, math]
proc parseLine(s: string): seq[seq[string]] = s.split(" | ").mapIt(it.split(" "))
proc p1(c: seq[string]): int =
c.reduce((a: int, l: string) =>
c.reduce((a: int, l) =>
a + l.parseLine()[1].reduce((b: int, h) => b + int(h.len() in [2, 3, 4, 7]), 0), 0)
proc numShared(s1: string, s2: string): int = (s1.toHashSet() * s2.toHashSet()).len()