-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16.py
38 lines (30 loc) · 887 Bytes
/
16.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from lib import *
input = read_input(2015, 16)
aunts = [
{k: int(v) for k, v in map(str.split, "".join(line.split()[2:]).replace(":", " ").split(","))}
for line in input.splitlines()
]
sue = {
"children": 3,
"cats": 7,
"samoyeds": 2,
"pomeranians": 3,
"akitas": 0,
"vizslas": 0,
"goldfish": 5,
"trees": 3,
"cars": 2,
"perfumes": 1,
}
for i, x in enumerate(aunts):
if all(k not in x or x[k] == v for k, v in sue.items()):
print(i + 1)
break
for i, x in enumerate(aunts):
if not all(k not in x or x[k] > sue[k] for k in ["cats", "trees"]):
continue
if not all(k not in x or x[k] < sue[k] for k in ["pomeranians", "goldfish"]):
continue
if all(k not in x or x[k] == v for k, v in sue.items() if k not in ["cats", "trees", "pomeranians", "goldfish"]):
print(i + 1)
break