26 lines
547 B
Python
26 lines
547 B
Python
most = {
|
|
"red": 12,
|
|
"green": 13,
|
|
"blue": 14
|
|
}
|
|
|
|
def is_valid(line):
|
|
picks = line.split(":")[1].strip().split(";")
|
|
for pick in picks:
|
|
draws = pick.split(", ")
|
|
for draw in draws:
|
|
[amount, color] = draw.strip().split(" ")
|
|
if int(amount) > most[color]:
|
|
return False
|
|
return True
|
|
|
|
id = 0
|
|
total = 0
|
|
with open("input.txt", "r") as f:
|
|
for line in f.readlines():
|
|
id += 1
|
|
if is_valid(line):
|
|
print("Possible!")
|
|
total += id
|
|
print(total)
|