advent-of-code/2023/1/obfuscated.py
2024-12-25 12:59:49 +01:00

6 lines
232 B
Python

import re
d="zero|one|two|three|four|five|six|seven|eight|nine|\\d)"
def f(l,p):
m=re.search(p,l)[1];return str(d.split("|").index(m)) if m in d else m
print(sum(map(lambda l:int(f(l,f"({d}.*")+f(l,".*("+d)),open(0).readlines())))