From 5607dba5f749314dc387eae9fe992b9935fff3b1 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