25 lines
538 B
Python
25 lines
538 B
Python
import re
|
|
|
|
lines = (list(map(lambda a: a.split(':'), x.strip().split())) for x in open("input.txt"))
|
|
|
|
passport = {}
|
|
count = 0
|
|
must_have = {'iyr', 'hcl', 'hgt', 'pid', 'ecl', 'eyr', 'byr'}
|
|
|
|
|
|
def check_passport(pp):
|
|
valid = len(set(pp).intersection(must_have)) == len(must_have)
|
|
if not valid:
|
|
return 0
|
|
return 1
|
|
|
|
|
|
for line in lines:
|
|
if len(line) == 0:
|
|
count += check_passport(passport)
|
|
passport = {}
|
|
for key, val in line:
|
|
passport[key] = val
|
|
count += check_passport(passport)
|
|
print(count)
|