Nouveau Repository
Je perd l'historique, mais ne stocke plus les fichiers input.txt entre autre choses
This commit is contained in:
16
day1/part1.py
Normal file
16
day1/part1.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import re
|
||||
|
||||
accumulator = 0
|
||||
with open("input.txt") as input:
|
||||
while line := input.readline():
|
||||
if match := re.match(".*?([0-9]).*([0-9]).*?", line):
|
||||
# print(match.groups(1))
|
||||
number = int(match.groups(1)[0] + match.groups(1)[1])
|
||||
# print(number)
|
||||
accumulator += number
|
||||
elif match := re.match(".*([0-9]).*", line):
|
||||
# print(match.groups(1))
|
||||
number = int(match.groups(1)[0] + match.groups(1)[0])
|
||||
# print(number)
|
||||
accumulator += number
|
||||
print(accumulator)
|
||||
Reference in New Issue
Block a user