From: Greg Burri Date: Mon, 12 Dec 2022 10:04:45 +0000 (+0100) Subject: little simplification X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=afba0665db5dda81b79706ae369cb42f785f8c23;p=advent_of_code_2022.git little simplification --- diff --git a/src/day12.rs b/src/day12.rs index ee08a24..fe30f0f 100644 --- a/src/day12.rs +++ b/src/day12.rs @@ -37,8 +37,7 @@ pub enum Path { pub fn nb_steps(hm: &Heightmap, path: Path) -> i32 { let (n, m) = (hm.elevations.len(), hm.elevations[0].len()); - let mut visited: Vec> = Vec::new(); - for _ in 0..n { visited.push(vec![-1; m]); } + let mut visited: Vec> = vec![vec![-1; m]; n]; let mut positions = vec![hm.end]; let mut next_positions = Vec::new(); let mut step = -1;