Advent of code

 16 décembre 2015 

  Aunt Sue :
  1. code.py
  2. input.txt
import json

ANALYSIS = {'children':3, 'cats':7, 'samoyeds':2, 'pomeranians':3, 'akitas':0, 'vizslas':0, 'goldfish':5, 'trees':3, 'cars':2, 'perfumes':1}

def isKeyCompatible(key, value):
    global ANALYSIS
    if key in ['cats', 'trees']:
        return ANALYSIS[key] < value
    if key in ['pomeranians', 'goldfish']:
        return ANALYSIS[key] > value
    return ANALYSIS[key] == value


SUES = []
f = open("input.txt", 'r')
lines = f.readlines()
for i in range(len(lines)):
    line = lines[i].split(',')
    sue = {}
    ok = True
    for token in line:
        token = token.split(':')
        k = token[0].strip()
        n = int(token[1].strip())
        sue[k] = n
        if not isKeyCompatible(k, n):
            ok = False
    if ok:
        print(i+1)