Skip to content

Commit 529657f

Browse files
committed
2023 d25: Add original solution
1 parent c647019 commit 529657f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2023/original_solutions/day25.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
3+
from utils.all import *
4+
5+
advent.setup(2023, 25)
6+
fin = advent.get_input()
7+
lines = read_lines(fin)
8+
9+
g = nx.Graph()
10+
11+
for line in lines:
12+
a, xb = line.split(': ')
13+
bs = set(map(str.strip, xb.split()))
14+
a = a.strip()
15+
16+
for b in bs:
17+
g.add_edge(a, b)
18+
19+
victims = nx.minimum_edge_cut(g)
20+
21+
for a, b in victims:
22+
g.remove_edge(a, b)
23+
24+
answer = prod(map(len, nx.connected_components(g)))
25+
26+
advent.print_answer(1, answer)

0 commit comments

Comments
 (0)