#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);