AoC - Day 25

:date: 2023-12-25 12:00

Part One

Looking through the other challenges, this caught my eye. The idea was that there was a big graph network but by cutting only 3 edges, you could separate it into two distinct networks. How can those critical edges be found?

Well, I suspected I knew a way. Graphviz is free software that does a superb job of making the most of plotting network graphs in a sane way. I knew it would not be a problem to convert the syntax of the puzzle to Graphviz's dot file syntax.

I did that easily enough which allowed me to produce this fine image.

25.png

This allowed me to figure out which three edges/wires needed to be cut. That entailed the following.

$ diff 25-input.dot 25-input-cut.dot 
100c100
< cth-> {dkq xxk dfs}
---
> cth-> {dkq dfs}
357c357
< zdj-> {nvt ffr sxq ftx lvk}
---
> zdj-> {ffr sxq ftx lvk}
821c821
< mzg-> {xln smx bbm}
---
> mzg-> {xln smx}

Then I used Python's networkx to count up the nodes in Python.

[source,py]

#!/usr/bin/python
import networkx as nx
G= nx.drawing.nx_pydot.read_dot('25-input-cut.dot')
regions= nx.weakly_connected_components(G)
A= 1
for c in regions: A*= len(c)
print(A)

And that produced the right answer!

Part Two

There really is not any part two. It is awarded if all other challenges, parts one and two, are complete.