Skip to content

Instantly share code, notes, and snippets.

@TimCastelijns
Created December 16, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimCastelijns/6134ad77d7af11fa377a to your computer and use it in GitHub Desktop.
Save TimCastelijns/6134ad77d7af11fa377a to your computer and use it in GitHub Desktop.
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])
first, second, third = False, False, False
for pair in [(name_1, nr_1), (name_2, nr_2), (name_3, nr_3)]:
if pair[0] in ('children', 'samoyeds', 'akitas',
'vizslas', 'cars', 'perfumes'):
if ticker[pair[0]] == pair[1]:
first = True
if pair[0] in ('cats', 'trees'):
if pair[1] > ticker[pair[0]]:
second = True
if pair[0] in ('pomeranians', 'goldfish'):
if pair[1] < ticker[pair[0]]:
third = True
if first and second and third:
print 'sue', sue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment