Compare commits
1 Commits
50f491c76f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
c35270a6a2
|
@@ -86,6 +86,12 @@ fn part1_memo(fwd: &Edges) -> u64 {
|
||||
|
||||
#[aoc(day11, part2, MemoDfs)]
|
||||
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("fft", "dac", edges)
|
||||
* count_paths("dac", "out", edges)
|
||||
|
||||
Reference in New Issue
Block a user