From: Greg Burri Date: Mon, 12 Dec 2022 10:04:45 +0000 (+0100) Subject: little simplification X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=5607dba5f749314dc387eae9fe992b9935fff3b1;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;