From afba0665db5dda81b79706ae369cb42f785f8c23 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Mon, 12 Dec 2022 11:04:45 +0100 Subject: [PATCH] little simplification --- src/day12.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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; -- 2.45.2