d1 - python (unfinished)

This commit is contained in:
Debucquoy Anthony 2023-12-01 18:05:14 +01:00
parent 6907bff638
commit c7a4428965
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 1020 additions and 0 deletions

20
2023/d1/d1.py Normal file
View File

@ -0,0 +1,20 @@
sum = 0
nums = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
with open("test.txt") as f:
for curr in f.readlines():
print(curr[:-1])
num = []
for c in range(len(curr)):
if curr[c].isnumeric():
num.append(curr[c])
break
for c in range(len(curr), 0, -1):
if curr[c-1].isnumeric():
num.append(curr[c-1])
break
print(int("".join(num)))
sum += int("".join(num))
print(sum)

1000
2023/d1/input.txt Normal file

File diff suppressed because it is too large Load Diff