diff --git a/src/bin/day17.rs b/src/bin/day17.rs index 37df9e5..0adf44b 100644 --- a/src/bin/day17.rs +++ b/src/bin/day17.rs @@ -49,19 +49,14 @@ impl Day17 { let (width, height) = (self.map[0].len(), self.map.len()); let goal = Vector2D::new(width as isize - 1, height as isize - 1); - let mut queue: MinHeap = MinHeap::new(); - queue.push(State { - heat_loss: 0, - distance: 0, - position: Vector2D::new(0, 0), - direction: Vector2D::new(1, 0), - }); - queue.push(State { - heat_loss: 0, - distance: 0, - position: Vector2D::new(0, 0), - direction: Vector2D::new(0, 1), - }); + let mut queue: MinHeap = MinHeap::from( + [Vector2D::new(1, 0), Vector2D::new(0, 1)].map(|direction| State { + heat_loss: 0, + distance: 0, + position: Vector2D::new(0, 0), + direction, + }), + ); let mut seen: HashSet<(Vector2D, Vector2D)> = HashSet::new(); while let Some(s) = queue.pop() {