mis en fonction

This commit is contained in:
Arthur 2023-12-02 19:13:36 +01:00
parent d4c55b73a1
commit 223ad87e08
2 changed files with 58 additions and 63 deletions

View File

@ -1,10 +1,4 @@
filename = "exemple1.txt"
#red / green / blue
bag = [12, 13, 14]
result = 0
def main(filename, bag, result = 0):
with open(filename, 'r') as f:
for line in f.readlines():
game = line.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]))

View File

@ -1,10 +1,4 @@
filename = "input.txt"
#red / green / blue
bag = [12, 13, 14]
result = 0
def main(filename, bag, result = 0):
with open(filename, 'r') as f:
for line in f.readlines():
game = line.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]))