mirror of
https://github.com/tanishq-dubey/aoc2023.git
synced 2024-12-28 00:37:22 -05:00
whoops forgot to commit
This commit is contained in:
parent
6b375f6a15
commit
324ad42383
28
day2/main.py
28
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)
|
||||
|
Loading…
Reference in New Issue
Block a user