From 611062693750297cfd53315721d15ee87ec33861 Mon Sep 17 00:00:00 2001 From: Tobias Marschner Date: Thu, 22 Feb 2024 22:09:32 +0100 Subject: [PATCH] Add early break condition for 2022/day12-part1 --- 2022/day12-part1/src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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.