From ee0cbf2ec592b28dca6d1142639e06de52ff1b3e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 9 Jul 2025 17:18:36 +0200 Subject: Day 24 2022 --- 2022/24/b.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 2022/24/b.rs (limited to '2022/24/b.rs') diff --git a/2022/24/b.rs b/2022/24/b.rs new file mode 100644 index 0000000..e6ca59f --- /dev/null +++ b/2022/24/b.rs @@ -0,0 +1,14 @@ +mod common; +use common::*; + +fn main() { + // The approach is greedy: once we reach the start / finish cell, + // we can wait there as long as we want, so it is always better + // to reach the partial destinations as soon as possible. + + let map = read_map_from_stdin(); + let a = map.shortest_path(Position::Start, Position::Finish, 0); + let b = map.shortest_path(Position::Finish, Position::Start, a); + let c = map.shortest_path(Position::Start, Position::Finish, b); + println!("{c}"); +} -- cgit v1.3