Add early break condition for 2022/day12-part1

This commit is contained in:
Tobias Marschner 2024-02-22 22:09:32 +01:00
parent 5928c3fbb3
commit 6110626937

View File

@ -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 &current_node.outgoing {
// Grab a mutable borrow to that neighbor.