summaryrefslogtreecommitdiff
path: root/day-8/script.ts
diff options
context:
space:
mode:
Diffstat (limited to 'day-8/script.ts')
-rw-r--r--day-8/script.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/day-8/script.ts b/day-8/script.ts
index 87e33cd..a9870c1 100644
--- a/day-8/script.ts
+++ b/day-8/script.ts
@@ -55,3 +55,13 @@ const result = startingNodes
.reduce((acc, x) => lcm(acc, x), 1);
console.log({ result });
+
+// Visualization into graphviz file
+// $ neato graph.dot -Tpng -o out.png
+const dotFile = "graph.dot";
+fs.writeFileSync(dotFile, "digraph aoc {\n");
+nodes.forEach((node) => {
+ fs.appendFileSync(dotFile, ` ${node.name} -> ${nodes[node.left].name};\n`);
+ fs.appendFileSync(dotFile, ` ${node.name} -> ${nodes[node.right].name};\n`);
+});
+fs.appendFileSync(dotFile, "}\n");