diff --git a/2022/day12-part1/src/main.rs b/2022/day12-part1/src/main.rs index d3b4927..ed44ab2 100644 --- a/2022/day12-part1/src/main.rs +++ b/2022/day12-part1/src/main.rs @@ -190,6 +190,13 @@ fn main() { // Grab a mutable borrow to the actual node. let current_node = map[current_vn.y][current_vn.x].borrow_mut(); + // Have we reached the destination? + // Then we're done here. + if current_node.x == dest_x && current_node.y == dest_y { + println!("Found the destination!"); + break; + } + // Now iterate through all neighbors. for nb in ¤t_node.outgoing { // Grab a mutable borrow to that neighbor.