generated from public/aoc_template
Day25 - foreign input
This commit is contained in:
parent
b053e244e4
commit
71da59865b
16
day25.py
16
day25.py
@ -1,7 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from tools.aoc import AOCDay
|
from tools.aoc import AOCDay
|
||||||
from tools.itertools import len_permutations
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ class Component:
|
|||||||
|
|
||||||
|
|
||||||
def separate(component1: Component, component2: Component) -> (int, int, int):
|
def separate(component1: Component, component2: Component) -> (int, int, int):
|
||||||
""" returns len(group1), len(group2), len(wires_to_disconnect)"""
|
"""returns len(group1), len(group2), len(wires_to_disconnect)"""
|
||||||
group1, group2, wires_to_disconnect = set(), set(), set()
|
group1, group2, wires_to_disconnect = set(), set(), set()
|
||||||
q1, q2 = deque([component1]), deque([component2])
|
q1, q2 = deque([component1]), deque([component2])
|
||||||
while q1 or q2:
|
while q1 or q2:
|
||||||
@ -61,7 +60,11 @@ class Wiring:
|
|||||||
connections = set()
|
connections = set()
|
||||||
for component in self.components.values():
|
for component in self.components.values():
|
||||||
for connection in component.connections:
|
for connection in component.connections:
|
||||||
connections.add((component.name, connection.name) if component.name < connection.name else (connection.name, component.name))
|
connections.add(
|
||||||
|
(component.name, connection.name)
|
||||||
|
if component.name < connection.name
|
||||||
|
else (connection.name, component.name)
|
||||||
|
)
|
||||||
|
|
||||||
return connections
|
return connections
|
||||||
|
|
||||||
@ -84,12 +87,13 @@ class Wiring:
|
|||||||
class Day(AOCDay):
|
class Day(AOCDay):
|
||||||
inputs = [
|
inputs = [
|
||||||
[
|
[
|
||||||
#(54, "input25_test"), # Test breaks sometimes. Live always works?!
|
# (54, "input25_test"), # Test breaks sometimes. Live always works?!
|
||||||
|
(545528, "input25_dennis"),
|
||||||
(544523, "input25"),
|
(544523, "input25"),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
(None, "input25"),
|
(None, "input25"),
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
def part1(self) -> Any:
|
def part1(self) -> Any:
|
||||||
@ -114,6 +118,6 @@ class Day(AOCDay):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
day = Day(2023, 25)
|
day = Day(2023, 25)
|
||||||
day.run(verbose=True)
|
day.run(verbose=True)
|
||||||
|
|||||||
1216
inputs/input25_dennis
Normal file
1216
inputs/input25_dennis
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user