(update) new aoc

This commit is contained in:
2025-12-19 10:46:29 +01:00
parent 7f3d06afdd
commit e5bef6f3da
3 changed files with 28 additions and 0 deletions

26
2025/02/main.py Normal file
View File

@ -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)