(update) new aoc
This commit is contained in:
1
2025/02/example
Normal file
1
2025/02/example
Normal file
@ -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
|
||||||
1
2025/02/input
Normal file
1
2025/02/input
Normal file
@ -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
|
||||||
26
2025/02/main.py
Normal file
26
2025/02/main.py
Normal 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)
|
||||||
Reference in New Issue
Block a user