Nouveau Repository

Je perd l'historique, mais ne stocke plus les fichiers input.txt
entre autre choses
This commit is contained in:
2023-12-02 12:45:07 +01:00
parent 3e06d85867
commit fbf1c66a39
6 changed files with 273 additions and 0 deletions

16
day1/part1.py Normal file
View 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)