aboutsummaryrefslogtreecommitdiff
path: root/2022/24/b.rs
blob: e6ca59ff7319656ab8e47c016c3300ef6f522850 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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}");
}

Generated with cgit - Back to sebastiano.tronto.net