2023-12-01 11:26:16 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
D = [str(i) for i in range(1,10)]
|
|
|
|
if sys.argv[1] == "2":
|
|
|
|
D += ['one','two','three','four','five','six','seven','eight','nine']
|
|
|
|
|
2023-12-04 15:13:55 +00:00
|
|
|
def process(l):
|
2023-12-01 11:26:16 +00:00
|
|
|
k = list()
|
2023-12-04 15:13:55 +00:00
|
|
|
for p in range(len(l)):
|
2023-12-01 11:26:16 +00:00
|
|
|
for i,d in enumerate(D):
|
|
|
|
if l[p:p+len(d)] == d:
|
|
|
|
k.append(i%9+1)
|
|
|
|
break
|
2023-12-04 15:13:55 +00:00
|
|
|
return k[0]*10 + k[-1] if len(k)>0 else 0
|
2023-12-01 11:26:16 +00:00
|
|
|
|
2023-12-04 15:13:55 +00:00
|
|
|
print(sum(process(l) for l in sys.stdin.read().splitlines()))
|