Compare commits

..

1 Commits

Author SHA1 Message Date
c35270a6a2 day11: perf 2025-12-12 11:51:57 -08:00

View File

@@ -86,6 +86,12 @@ fn part1_memo(fwd: &Edges) -> u64 {
#[aoc(day11, part2, MemoDfs)] #[aoc(day11, part2, MemoDfs)]
fn part2_memo(edges: &Edges) -> u64 { fn part2_memo(edges: &Edges) -> u64 {
// we assume all valid paths reach svr->fft->dac->out in that order. this holds on the example and the input.
// to handle both possible orderings, we need to sum paths fft->dac and dac->fft, and then partition the graph
// (just remove the node) at dac & fft before computing the sum of dac->out and fft->out.
//
// this is our performance implementation though and it's faster to not do that work. we do the posterity for the
// naive solution
count_paths("svr", "fft", edges) count_paths("svr", "fft", edges)
* count_paths("fft", "dac", edges) * count_paths("fft", "dac", edges)
* count_paths("dac", "out", edges) * count_paths("dac", "out", edges)