diff --git a/day2/main.py b/day2/main.py index 25fc281..f09f077 100644 --- a/day2/main.py +++ b/day2/main.py @@ -1,4 +1,3 @@ - fname = "input" data = [] @@ -39,3 +38,30 @@ for d in data: total = total + gid print(total) + +total = 0 +for d in data: + mins = { + "red": 0, + "blue": 0, + "green": 0, + } + ginfo = d.split(":") + gid = int(ginfo[0].split("Game")[-1]) + sets = ginfo[-1].split(";") + for s in sets: + d = s.split(",") + for item in d: + item = item.strip() + vals = item.split(" ") + color = vals[-1] + count = int(vals[0]) + if mins[color] < count: + mins[color] = count + stotal = 1 + for k, v in mins.items(): + stotal = stotal * v + total = total + stotal + print(mins, gid, stotal) + +print(total)