Skip to content

Commit f7d6bd1

Browse files
committed
Add solution to 2025-12-11
1 parent 0f3c629 commit f7d6bd1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

2025/day11/solutions.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from functools import cache
2+
import networkx as nx
3+
4+
with open("input") as f:
5+
ls = f.read().splitlines()
6+
7+
G = nx.DiGraph()
8+
for l in ls:
9+
start, *to = l.split()
10+
for p in to:
11+
G.add_edge(start[:-1], p)
12+
13+
# Part 1
14+
print(len(list(nx.all_simple_paths(G, source="you", target="out"))))
15+
16+
17+
# Part 2
18+
@cache
19+
def paths_from(node, dac_seen, fft_seen):
20+
if node == "out":
21+
return dac_seen and fft_seen
22+
dac_seen = dac_seen or node == "dac"
23+
fft_seen = fft_seen or node == "fft"
24+
return sum(paths_from(to_node, dac_seen, fft_seen) for to_node in G.neighbors(node))
25+
26+
27+
print(paths_from("svr", False, False))

0 commit comments

Comments
 (0)