From e5bef6f3daff6be65c84e45527de5c655a71b5d8 Mon Sep 17 00:00:00 2001 From: TobenderZephyr Date: Fri, 19 Dec 2025 10:46:29 +0100 Subject: [PATCH] (update) new aoc --- 2025/02/example | 1 + 2025/02/input | 1 + 2025/02/main.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 2025/02/example create mode 100644 2025/02/input create mode 100644 2025/02/main.py diff --git a/2025/02/example b/2025/02/example new file mode 100644 index 0000000..bd04584 --- /dev/null +++ b/2025/02/example @@ -0,0 +1 @@ +11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124 \ No newline at end of file diff --git a/2025/02/input b/2025/02/input new file mode 100644 index 0000000..d6b119a --- /dev/null +++ b/2025/02/input @@ -0,0 +1 @@ +8123221734-8123333968,2665-4538,189952-274622,4975-9031,24163352-24202932,1233-1772,9898889349-9899037441,2-15,2147801-2281579,296141-327417,8989846734-8989940664,31172-42921,593312-632035,862987-983007,613600462-613621897,81807088-81833878,13258610-13489867,643517-782886,986483-1022745,113493-167913,10677-16867,372-518,3489007333-3489264175,1858-2534,18547-26982,16-29,247-366,55547-103861,57-74,30-56,1670594-1765773,76-129,134085905-134182567,441436-566415,7539123416-7539252430,668-1146,581563513-581619699 \ No newline at end of file diff --git a/2025/02/main.py b/2025/02/main.py new file mode 100644 index 0000000..c31ea95 --- /dev/null +++ b/2025/02/main.py @@ -0,0 +1,26 @@ +#!/bin/env python3 + +with open("input", "+r") as file: + line = file.readline() + ranges = line.split(",") + invalid = 0 + INVALID_NUMBERS = [] + for values in ranges: + low = int(values.split("-")[0]) + high = int(values.split("-")[1]) + for i in range(low, high + 1): + to_string = str(i) + split_max = int(to_string.__len__() / 2) + for split_at in range(1, split_max + 1): + if i in INVALID_NUMBERS: + continue + left = to_string[:split_at] + has_to_have: float = to_string.__len__() / split_at + if not has_to_have.is_integer(): + continue + if to_string.count(left) == has_to_have: + INVALID_NUMBERS.append(i) + invalid = invalid + i + print(f"{i} is invalid.") + print(INVALID_NUMBERS) + print("result", invalid)