1
0
Fork 0

day(17): use ‹From› on ‹MinHeap›

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2023-12-17 18:26:26 +01:00
parent 12322c9fae
commit 07d9b05904
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -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<State> = MinHeap::new();
queue.push(State {
let mut queue: MinHeap<State> = MinHeap::from(
[Vector2D::new(1, 0), Vector2D::new(0, 1)].map(|direction| 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),
});
direction,
}),
);
let mut seen: HashSet<(Vector2D<isize>, Vector2D<isize>)> = HashSet::new();
while let Some(s) = queue.pop() {