aoc2020/04/1.py

7 lines
360 B
Python
Raw Permalink Normal View History

2020-12-04 09:35:58 +00:00
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))