adventofcode/2023/d1/d1.py

21 lines
538 B
Python
Raw Normal View History

2023-12-01 18:05:14 +01:00
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)