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
482 B

lines = 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:
break
sum += int(first + last)
print(sum)