summaryrefslogtreecommitdiff
path: root/2025/aoc2025-d11.py
diff options
context:
space:
mode:
Diffstat (limited to '2025/aoc2025-d11.py')
-rw-r--r--2025/aoc2025-d11.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/2025/aoc2025-d11.py b/2025/aoc2025-d11.py
new file mode 100644
index 0000000..86af8aa
--- /dev/null
+++ b/2025/aoc2025-d11.py
@@ -0,0 +1,35 @@
+#advent of code 2025
+#day 11
+#more reading for later, maybe there's a different algo than dfs/bfs
+# https://en.wikipedia.org/wiki/Directed_acyclic_graph
+#no idea why my format doesn't work
+#below is format which was shamelessly stolen from someone else
+#don't sue me
+#will rewrite it later as a product
+#possible paths svr-fft; possible paths fft-dac; possible paths dac-out
+
+from functools import cache
+
+connections=dict();
+PuzzleInput=open("11.in","r");
+for l in PuzzleInput:
+ vertex,nodes=l.strip().split(": ");
+ if vertex not in connections: connections[vertex]=set();
+ connections[vertex].update(nodes.split())
+
+@cache
+def findpaths(pos,fft,dac):
+ if pos=="out":
+ return 1*fft*dac;
+ score=0;
+ fft_=fft or pos=="fft";
+ dac_=dac or pos=="dac";
+ for con in connections[pos]:
+ score+=findpaths(con,fft_,dac_);
+ return score;
+
+part1=findpaths("you",True,True);
+part2=findpaths("svr",False,False);
+
+print("part 1 =",part1);
+print("part 2 =",part2);