adventofcode-2020/04/part1

19 lines
462 B
Plaintext
Raw Normal View History

2020-12-13 15:34:03 +01:00
#!/usr/bin/python3
required_fields = { "byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid",}
valid = 0
with open("input") as fh:
all_data = fh.read()
passport_strings = all_data.split("\n\n")
for ps in passport_strings:
fields = ps.split()
passport = {}
for f in fields:
k, v = f.split(":")
passport[k] = v
if required_fields - set(passport.keys()) == set():
valid += 1
print(valid)