From ff448231e39e337dbf8675ccd39072328e02be91 Mon Sep 17 00:00:00 2001 From: Starnakin Date: Tue, 2 Dec 2025 13:26:23 +0100 Subject: [PATCH] add: day02: part1 --- 2025/day02/part1.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 2025/day02/part1.py diff --git a/2025/day02/part1.py b/2025/day02/part1.py new file mode 100644 index 0000000..185607d --- /dev/null +++ b/2025/day02/part1.py @@ -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) \ No newline at end of file