add: day02: part1

This commit is contained in:
2025-12-02 13:26:23 +01:00
parent d5ba743679
commit ff448231e3

16
2025/day02/part1.py Normal file
View File

@ -0,0 +1,16 @@
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)