-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Day15b runtime can be improved by bucket queue #8
Comments
Fantastic suggestion. Thanks so much for sharing this. I wasn't aware of the bucket queue structure. I'd like to focus on the other days first. I'll likely try to implement this afterwards. Feel free to PR in the mean time. |
Nice one solution! I can actually also recommend using the astar method (from the same library), got a 2x speedup over Dijkstra. (finds the same path) ;) |
Interesting. I got slightly slower times while using A*. I actually started with A*, but switched to Dijkstra due to better timings. I wonder what may have caused this. Maybe my implementation was broken. But it could also be hardware configuration related. |
hmm, could it be due to distance calculations? |
Possibly. What did you use? |
fn distance(&self, other: &Pos) -> i32 {
let square_dist = (self.0 - other.0).abs().pow(2) + (self.1 - other.1).abs().pow(2);
(square_dist as f64).sqrt() as i32
} But I wonder if it would be possible to profile the timing. |
The
pathfinding
library implements classic dijkstra's algorithm by a BinaryHeap.It can be further improved, some of my thoughts are:
I implemented the bucket queue dijkstra and it's around 20% faster than the binary heap approach on day15b setup.
The text was updated successfully, but these errors were encountered: