day(17): use ‹From› on ‹MinHeap›
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
12322c9fae
commit
07d9b05904
1 changed files with 8 additions and 13 deletions
|
@ -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 {
|
||||
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<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,
|
||||
}),
|
||||
);
|
||||
|
||||
let mut seen: HashSet<(Vector2D<isize>, Vector2D<isize>)> = HashSet::new();
|
||||
while let Some(s) = queue.pop() {
|
||||
|
|
Loading…
Reference in a new issue