You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
498 B
20 lines
498 B
lines = [i for i in open("input.txt", 'r').read().splitlines()]
|
|
|
|
sum = 0
|
|
|
|
for l in lines:
|
|
first = ""
|
|
firstFound = False
|
|
last = ""
|
|
lastFound = False
|
|
for i in range(len(l)):
|
|
if not firstFound and l[i].isnumeric():
|
|
first = l[i]
|
|
firstFound = True
|
|
if not lastFound and l[-i-1].isnumeric():
|
|
last = l[-i-1]
|
|
lastFound = True
|
|
if firstFound and lastFound:
|
|
continue
|
|
sum += int(first + last)
|
|
print(sum) |