Use more appropriate sequtils templates

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

View file

@ -21,8 +21,7 @@ proc hasRequiredFields(p: Table[string, string]): bool =
toSeq(validators.keys).toHashSet.difference(["cid"].toHashSet) <= toSeq(p.keys).toHashSet
proc part1*(s: Stream): int =
s.parsePassports.filterIt(it.hasRequiredFields).len
s.parsePassports.countIt(it.hasRequiredFields)
proc part2*(s: Stream): int =
s.parsePassports.filterIt(it.hasRequiredFields and
toSeq(it.pairs).mapIt(validators[it[0]](it[1])).foldl(a and b)).len
s.parsePassports.countIt(it.hasRequiredFields and toSeq(it.pairs).allIt(validators[it[0]](it[1])))