Use sets difference in operator-style

This commit is contained in:
Daniel Flanagan 2020-12-04 10:31:44 -06:00
parent 2c5d254720
commit 541279fa25
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -18,7 +18,7 @@ proc parsePassports(s: Stream): seq[Table[string, string]] =
.filterIt(it != "").mapIt(it.split(':', 2)).mapIt((it[0], it[1])).toTable)
proc hasRequiredFields(p: Table[string, string]): bool =
toSeq(validators.keys).toHashSet.difference(["cid"].toHashSet) <= toSeq(p.keys).toHashSet
(toSeq(validators.keys).toHashSet - ["cid"].toHashSet) <= toSeq(p.keys).toHashSet
proc part1*(s: Stream): int =
s.parsePassports.countIt(it.hasRequiredFields)