Skip to content

Commit a4ba2a0

Browse files
committed
Add day11, 2025
1 parent d881e29 commit a4ba2a0

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

2025/day11/solution.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import networkx as nx
2+
from functools import cache
3+
4+
with open("input") as f:
5+
inp = f.read().strip().split("\n")
6+
7+
g = nx.DiGraph()
8+
for line in inp:
9+
in_, outs = line.split(": ")
10+
for out in outs.split():
11+
g.add_edge(in_, out)
12+
13+
# Part 1
14+
print(len(list(nx.all_simple_paths(g, "you", "out"))))
15+
16+
# Part 2
17+
@cache
18+
def no_paths(fr, to, fft = False, dac = False):
19+
fft = fft or (fr == "fft")
20+
dac = dac or (fr == "dac")
21+
if fr == to:
22+
return 1 if fft and dac else 0
23+
return sum(no_paths(neighbor, to, fft, dac) for neighbor in g.neighbors(fr))
24+
25+
26+
print(no_paths("svr", "out"))

0 commit comments

Comments
 (0)