Add dot file to 2021 day 12.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Mikaël Capelle 2024-12-14 22:34:22 +01:00
parent 2c5c51e05f
commit b15131bf1e

View File

@ -46,5 +46,19 @@ class Solver(BaseSolver):
if b != "end" and a != "start": if b != "end" and a != "start":
neighbors[b].append(a) neighbors[b].append(a)
if self.files:
graph = "graph {\n"
for node, neighbors_of in neighbors.items():
graph += (
" ".join(
f"{node} -- {neighbor};"
for neighbor in neighbors_of
if node <= neighbor or node == "start" or neighbor == "end"
)
+ "\n"
)
graph += "}\n"
self.files.create("graph.dot", graph.encode(), False)
yield len(list(enumerate_paths(neighbors))) yield len(list(enumerate_paths(neighbors)))
yield len(list(enumerate_paths(neighbors, 1))) yield len(list(enumerate_paths(neighbors, 1)))