1
0

Add solution for "Day 4: Printing Department", part 2

This commit is contained in:
Stefan Müller
2026-02-05 09:58:16 +01:00
parent b746cad9ae
commit 7a55f0be92
5 changed files with 106 additions and 38 deletions
+4
View File
@@ -34,6 +34,10 @@ With a continuously updated tally of the current best joltage initialized at zer
:mag_right: Puzzle: <https://adventofcode.com/2025/day/4>, :white_check_mark: Solver: [`PrintingDepartment`](src/solvers/printing_department.rs)
For part 1, we create a two-dimensional grid to track location and neighbor counts for each paper roll. Parsing the input data row by row, for each location we only have to check the four neighbors that were not yet encountered, i.e. right in the same row, and the three neighbors in the next row, to handle all pairs of locations. This means that we know whether a location is accessible or not immediately before moving on to the next.
For part 2, the accessible locations are tracked, and removed individually from the grid. After each removal, the neighbor counts of the neighbors are updated. Any of the neighbors that now fall under the threshold are counted as well and added to the removal list.
### Day 5: Cafeteria
:mag_right: Puzzle: <https://adventofcode.com/2025/day/5>, :white_check_mark: Solver: [`Cafeteria`](src/solvers/cafeteria.rs)