aoc2020/04/1.py
2020-12-04 09:36:20 +00:00

7 lines
360 B
Python

sections = open("input", "r").read().split("\n\n")
sections = [section.replace("\n", " ") for section in sections]
passports = [dict([s.split(":") for s in section.split(" ") if s]) for section in sections]
required = {"byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"}
valid = [p for p in passports if len(required.difference(p.keys())) == 0]
print(len(valid))