Created
December 16, 2015 13:40
-
-
Save TimCastelijns/326c04742d76528e3466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ticker = { | |
'children': 3, | |
'cats': 7, | |
'samoyeds': 2, | |
'pomeranians': 3, | |
'akitas': 0, | |
'vizslas': 0, | |
'goldfish': 5, | |
'trees': 3, | |
'cars': 2, | |
'perfumes': 1 | |
} | |
with open('day16.txt', 'r') as f: | |
for sue, line in enumerate(f.readlines(), start=1): | |
parts = line.split() | |
name_1 = parts[2][:-1] | |
nr_1 = int(parts[3][:-1]) | |
name_2 = parts[4][:-1] | |
nr_2 = int(parts[5][:-1]) | |
name_3 = parts[6][:-1] | |
nr_3 = int(parts[7]) | |
if all(ticker[pair[0]] == pair[1] for pair in | |
[(name_1, nr_1), (name_2, nr_2), (name_3, nr_3)]): | |
print 'sue ', sue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment