solution for 02p1 and 02p2, also started with 03
This commit is contained in:
29
02/02p2.py
Executable file
29
02/02p2.py
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
inputfile = open("input.txt", "r")
|
||||
lines = inputfile.readlines()
|
||||
|
||||
sol = 0
|
||||
|
||||
for line in lines:
|
||||
line = line.replace('\n', "")
|
||||
gameid = line.split(":")[0].split(" ")[1]
|
||||
games = line.split(":")[1].split(";")
|
||||
maxred = 0
|
||||
maxgreen = 0
|
||||
maxblue = 0
|
||||
for pull in games:
|
||||
colors = pull.split(',')
|
||||
for color in colors:
|
||||
temp = color.split(' ')
|
||||
if 'red' in temp[2]:
|
||||
if int(temp[1]) > maxred:
|
||||
maxred = int(temp[1])
|
||||
elif 'green' in temp[2]:
|
||||
if int(temp[1]) > maxgreen:
|
||||
maxgreen = int(temp[1])
|
||||
elif 'blue' in temp[2]:
|
||||
if int(temp[1]) > maxblue:
|
||||
maxblue = int(temp[1])
|
||||
sol += maxred * maxgreen * maxblue
|
||||
print(sol)
|
Reference in New Issue
Block a user