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