Add solution for "Day 8: Playground", part 2
This commit is contained in:
@@ -60,6 +60,12 @@ Going row by row, for each column in the input data we count the number of diffe
|
||||
|
||||
:mag_right: Puzzle: <https://adventofcode.com/2025/day/8>, :white_check_mark: Solver: [`Playground`](src/solvers/playground.rs)
|
||||
|
||||
For part 1 we track a number of smallest distances between junction boxes up to the specified maximum in a priority queue, always dropping the highest when we find a better one. At the end, we use these to find connected circuits, and count their sizes.
|
||||
|
||||
For part 2 we instead construct a spanning tree of all junction boxes, such that the maximum distance between any pair is minimal. Once all junction boxes have been added to this graph, the pair of junction boxes with the longest distance in the spanning tree.
|
||||
|
||||
When adding any new junction box, we either take connect it via the shortest edge, if it is already longer than the current maximum in the tree. Otherwise, we connect it via the first edge shorter than the current maximum, and for additional edges shorter than the current maximum we find the longest edge on the unique path between the two vertices now already connected, remove it, and add the new shorter one. The current maximum is tracked again in a separate priority queue, and eventually gives the solution.
|
||||
|
||||
### Day 9: Movie Theater
|
||||
|
||||
:mag_right: Puzzle: <https://adventofcode.com/2025/day/9>, :white_check_mark: Solver: [`MovieTheater`](src/solvers/movie_theater.rs)
|
||||
|
||||
Reference in New Issue
Block a user