diff --git a/2020/src/day4.nim b/2020/src/day4.nim index 1a896c2..81330d5 100644 --- a/2020/src/day4.nim +++ b/2020/src/day4.nim @@ -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])))