This commit is contained in:
Pim Kunis 2023-12-25 13:51:14 +01:00
parent 18797afee1
commit 0dda547a5a
4 changed files with 1247 additions and 0 deletions

13
23/day25/example.txt Normal file
View file

@ -0,0 +1,13 @@
jqt: rhn xhk nvd
rsh: frs pzl lsr
xhk: hfx
cmg: qnr nvd lhk bvb
rhn: xhk bvb hfx
bvb: xhk hfx
pzl: lsr hfx nvd
qnr: nvd
ntq: jqt hfx bvb xhk
nvd: lhk
lsr: lhk
rzs: qnr cmg lsr rsh
frs: qnr lhk lsr

1212
23/day25/input.txt Normal file

File diff suppressed because it is too large Load diff

21
23/day25/main.py Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import networkx as nx
G = nx.Graph()
with open("input.txt", "r") as f:
for line in f:
pieces = line.strip().split(": ")
start = pieces[0]
for end in pieces[1].split(" "):
G.add_edge(start, end)
cut_edges = nx.minimum_edge_cut(G)
G.remove_edges_from(cut_edges)
part1 = 1
for subgraph in (G.subgraph(c) for c in nx.connected_components(G)):
part1 *= subgraph.number_of_nodes()
print(part1)

View file

@ -0,0 +1 @@
networkx==3.2.1