For Part One I used a depth-first search which took too long for part two. Part Two I created an adjacency list of the junction points while keeping track of the distance to the adjacent nodes at the same time. Then depth-first search through the adjacency list.
Rust
Blunt force grid navigation https://gitlab.com/landreville/advent-of-code-2024/-/blob/main/src/bin/04.rs