From 686db2cd8e23ea0a17ec62f2ecb5c9fccd9f092e Mon Sep 17 00:00:00 2001 From: Starnakin Date: Wed, 3 Dec 2025 12:41:53 +0100 Subject: [PATCH] add: day03: part2 --- 2025/day03/part2.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 2025/day03/part2.py diff --git a/2025/day03/part2.py b/2025/day03/part2.py new file mode 100644 index 0000000..d2d3d9d --- /dev/null +++ b/2025/day03/part2.py @@ -0,0 +1,21 @@ +text: str + +with open("input.txt") as f: + text = f.read() + +total: int = 0 + +for line in text.splitlines(): + lst = [int(char) for char in line] + result: str = "" + start_index: int = 0 + for i in range(0, 12): + stop_index: int = i - 11 if i != 11 else len(lst) + sublst = lst[start_index:stop_index] + max_value = max(sublst) + result += str(max_value) + start_index = start_index + sublst.index(max_value) + 1 + total += int(result) + + +print(total) \ No newline at end of file