d1 - python (unfinished)
This commit is contained in:
parent
6907bff638
commit
c7a4428965
20
2023/d1/d1.py
Normal file
20
2023/d1/d1.py
Normal 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
1000
2023/d1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user