mis en fonction
This commit is contained in:
parent
d4c55b73a1
commit
223ad87e08
16
d02/run1.py
16
d02/run1.py
|
@ -1,11 +1,5 @@
|
|||
filename = "exemple1.txt"
|
||||
|
||||
#red / green / blue
|
||||
bag = [12, 13, 14]
|
||||
|
||||
result = 0
|
||||
|
||||
with open(filename, 'r') as f:
|
||||
def main(filename, bag, result = 0):
|
||||
with open(filename, 'r') as f:
|
||||
for line in f.readlines():
|
||||
game = line.split(": ")
|
||||
p = game[1].replace("\n","").split("; ")
|
||||
|
@ -32,4 +26,8 @@ with open(filename, 'r') as f:
|
|||
result -= i
|
||||
break
|
||||
|
||||
print(result)
|
||||
return result
|
||||
|
||||
if __name__ == '__main__':
|
||||
#red / green / blue
|
||||
print(main("input.txt", [12, 13, 14]))
|
15
d02/run2.py
15
d02/run2.py
|
@ -1,11 +1,5 @@
|
|||
filename = "input.txt"
|
||||
|
||||
#red / green / blue
|
||||
bag = [12, 13, 14]
|
||||
|
||||
result = 0
|
||||
|
||||
with open(filename, 'r') as f:
|
||||
def main(filename, bag, result = 0):
|
||||
with open(filename, 'r') as f:
|
||||
for line in f.readlines():
|
||||
game = line.split(": ")
|
||||
p = game[1].replace("\n","").split("; ")
|
||||
|
@ -27,5 +21,8 @@ with open(filename, 'r') as f:
|
|||
max[2] = int(k[0])
|
||||
somme = max[0] * max[1] * max[2]
|
||||
result += somme
|
||||
return result
|
||||
|
||||
print(result)
|
||||
if __name__ == '__main__':
|
||||
#red / green / blue
|
||||
print(main("input.txt", [12, 13, 14]))
|
Loading…
Reference in New Issue