aboutsummaryrefslogtreecommitdiff
path: root/2022/24/b.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/24/b.rs')
-rw-r--r--2022/24/b.rs14
1 files changed, 14 insertions, 0 deletions
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 @@
1mod common;
2use common::*;
3
4fn main() {
5 // The approach is greedy: once we reach the start / finish cell,
6 // we can wait there as long as we want, so it is always better
7 // to reach the partial destinations as soon as possible.
8
9 let map = read_map_from_stdin();
10 let a = map.shortest_path(Position::Start, Position::Finish, 0);
11 let b = map.shortest_path(Position::Finish, Position::Start, a);
12 let c = map.shortest_path(Position::Start, Position::Finish, b);
13 println!("{c}");
14}

Generated with cgit - Back to sebastiano.tronto.net