import math text: str with open("input.txt") as f: text = f.read() total: int = 0 for start, stop in [line.split("-") for line in text.split(",")]: for value in range(int(start), int(stop) + 1): length: int = int(math.log10(value)) if length % 2 == 1: value_str: str = str(value) if (value_str[0:length // 2 + 1] == value_str[length // 2 + 1:]): total += value print(total)