17 lines
273 B
Python
17 lines
273 B
Python
import re
|
|
|
|
with open("input", "r") as f:
|
|
line = f.read()
|
|
|
|
ranges = line.split(",")
|
|
|
|
s = 0
|
|
|
|
for _range in ranges:
|
|
start, end = list(map(int, _range.split("-")))
|
|
for i in range(start, end+1):
|
|
if re.match(r"^(.+)\1$", str(i)):
|
|
s += i
|
|
|
|
print(s)
|