Code of the Advent kind, maybe in Go this year
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
517 B

12 months ago
#!/usr/bin/env python3
from sys import argv
inp = {int(x.split()[1]): [{a.split()[1]: int(a.split()[0]) for a in z.split(",")} for z in y.split(";")] for x, y in map(lambda x: x.split(":"), open(argv[1]).readlines())}
print(sum([x for x, y in inp.items() if all([z.get("red", 0) <= 12 and z.get("green", 0) <= 13 and z.get("blue", 0) <= 14 for z in y])]))
print(sum(max(map(lambda x: x.get("red", 0), y)) * max(map(lambda x: x.get("green", 0), y)) * max(map(lambda x: x.get("blue", 0), y)) for x, y in inp.items()))