import re

whitespace = re.compile('\s')

passports = []
with open('days/4/input') as f:
  for entry in f.read().split('\n\n'):
      fields = whitespace.split(entry.strip())
      passport_pairs = {}
      for field in fields:
          key, value = field.split(':')
          passport_pairs[key] = value
      passports.append(passport_pairs)



required_fields = set([
  'byr', # (Birth Year)
  'iyr', # (Issue Year)
  'eyr', # (Expiration Year)
  'hgt', # (Height)
  'hcl', # (Hair Color)
  'ecl', # (Eye Color)
  'pid', # (Passport ID)
  # 'cid', # (Country ID)
])


print(len([p for p in passports if all([k in p.keys() for k in required_fields])]))

# print(passports)

772790b1aaa389f40ba0576f51346b4d7bb3efbb
<mask token>

<mask token>
with open('days/4/input') as f:
    for entry in f.read().split('\n\n'):
        fields = whitespace.split(entry.strip())
        passport_pairs = {}
        for field in fields:
            key, value = field.split(':')
            passport_pairs[key] = value
        passports.append(passport_pairs)
<mask token>
print(len([p for p in passports if all([(k in p.keys()) for k in
    required_fields])]))

<mask token>
whitespace = re.compile('\\s')
passports = []
with open('days/4/input') as f:
    for entry in f.read().split('\n\n'):
        fields = whitespace.split(entry.strip())
        passport_pairs = {}
        for field in fields:
            key, value = field.split(':')
            passport_pairs[key] = value
        passports.append(passport_pairs)
required_fields = set(['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'])
print(len([p for p in passports if all([(k in p.keys()) for k in
    required_fields])]))

import re
whitespace = re.compile('\\s')
passports = []
with open('days/4/input') as f:
    for entry in f.read().split('\n\n'):
        fields = whitespace.split(entry.strip())
        passport_pairs = {}
        for field in fields:
            key, value = field.split(':')
            passport_pairs[key] = value
        passports.append(passport_pairs)
required_fields = set(['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'])
print(len([p for p in passports if all([(k in p.keys()) for k in
    required_fields])]))

import re

whitespace = re.compile('\s')

passports = []
with open('days/4/input') as f:
  for entry in f.read().split('\n\n'):
      fields = whitespace.split(entry.strip())
      passport_pairs = {}
      for field in fields:
          key, value = field.split(':')
          passport_pairs[key] = value
      passports.append(passport_pairs)



required_fields = set([
  'byr', # (Birth Year)
  'iyr', # (Issue Year)
  'eyr', # (Expiration Year)
  'hgt', # (Height)
  'hcl', # (Hair Color)
  'ecl', # (Eye Color)
  'pid', # (Passport ID)
  # 'cid', # (Country ID)
])


print(len([p for p in passports if all([k in p.keys() for k in required_fields])]))

# print(passports)
