2025 Day 4 Complete!
This commit is contained in:
236
2025/day04/problem
Normal file
236
2025/day04/problem
Normal file
@@ -0,0 +1,236 @@
|
||||
Advent of Code
|
||||
br0xen [7](AoC++) 8*
|
||||
|
||||
--- Day 4: Printing Department ---
|
||||
|
||||
You ride the escalator down to the printing department. They're clearly
|
||||
getting ready for Christmas; they have lots of large rolls of paper
|
||||
everywhere, and there's even a massive printer in the corner (to handle
|
||||
the really big print jobs).
|
||||
|
||||
Decorating here will be easy: they can make their own decorations. What
|
||||
you really need is a way to get further into the North Pole base while the
|
||||
elevators are offline.
|
||||
|
||||
"Actually, maybe we can help with that," one of the Elves replies when you
|
||||
ask for help. "We're pretty sure there's a cafeteria on the other side of
|
||||
the back wall. If we could break through the wall, you'd be able to keep
|
||||
moving. It's too bad all of our forklifts are so busy moving those big
|
||||
rolls of paper around."
|
||||
|
||||
If you can optimize the work the forklifts are doing, maybe they would
|
||||
have time to spare to break through the wall.
|
||||
|
||||
The rolls of paper (@) are arranged on a large grid; the Elves even have a
|
||||
helpful diagram (your puzzle input) indicating where everything is
|
||||
located.
|
||||
|
||||
For example:
|
||||
|
||||
..@@.@@@@.
|
||||
@@@.@.@.@@
|
||||
@@@@@.@.@@
|
||||
@.@@@@..@.
|
||||
@@.@@@@.@@
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
@.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
@.@.@@@.@.
|
||||
|
||||
The forklifts can only access a roll of paper if there are fewer than four
|
||||
rolls of paper in the eight adjacent positions. If you can figure out
|
||||
which rolls of paper the forklifts can access, they'll spend less time
|
||||
looking and more time breaking down the wall to the cafeteria.
|
||||
|
||||
In this example, there are 13 rolls of paper that can be accessed by a
|
||||
forklift (marked with x):
|
||||
|
||||
..xx.xx@x.
|
||||
x@@.@.@.@@
|
||||
@@@@@.x.@@
|
||||
@.@@@@..@.
|
||||
x@.@@@@.@x
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
x.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
x.x.@@@.x.
|
||||
|
||||
Consider your complete diagram of the paper roll locations. How many rolls
|
||||
of paper can be accessed by a forklift?
|
||||
|
||||
Your puzzle answer was 1346.
|
||||
|
||||
--- Part Two ---
|
||||
|
||||
Now, the Elves just need help accessing as much of the paper as they can.
|
||||
|
||||
Once a roll of paper can be accessed by a forklift, it can be removed.
|
||||
Once a roll of paper is removed, the forklifts might be able to access
|
||||
more rolls of paper, which they might also be able to remove. How many
|
||||
total rolls of paper could the Elves remove if they keep repeating this
|
||||
process?
|
||||
|
||||
Starting with the same example as above, here is one way you could remove
|
||||
as many rolls of paper as possible, using highlighted @ to indicate that a
|
||||
roll of paper is about to be removed, and using x to indicate that a roll
|
||||
of paper was just removed:
|
||||
|
||||
Initial state:
|
||||
..@@.@@@@.
|
||||
@@@.@.@.@@
|
||||
@@@@@.@.@@
|
||||
@.@@@@..@.
|
||||
@@.@@@@.@@
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
@.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
@.@.@@@.@.
|
||||
|
||||
Remove 13 rolls of paper:
|
||||
..xx.xx@x.
|
||||
x@@.@.@.@@
|
||||
@@@@@.x.@@
|
||||
@.@@@@..@.
|
||||
x@.@@@@.@x
|
||||
.@@@@@@@.@
|
||||
.@.@.@.@@@
|
||||
x.@@@.@@@@
|
||||
.@@@@@@@@.
|
||||
x.x.@@@.x.
|
||||
|
||||
Remove 12 rolls of paper:
|
||||
.......x..
|
||||
.@@.x.x.@x
|
||||
x@@@@...@@
|
||||
x.@@@@..x.
|
||||
.@.@@@@.x.
|
||||
.x@@@@@@.x
|
||||
.x.@.@.@@@
|
||||
..@@@.@@@@
|
||||
.x@@@@@@@.
|
||||
....@@@...
|
||||
|
||||
Remove 7 rolls of paper:
|
||||
..........
|
||||
.x@.....x.
|
||||
.@@@@...xx
|
||||
..@@@@....
|
||||
.x.@@@@...
|
||||
..@@@@@@..
|
||||
...@.@.@@x
|
||||
..@@@.@@@@
|
||||
..x@@@@@@.
|
||||
....@@@...
|
||||
|
||||
Remove 5 rolls of paper:
|
||||
..........
|
||||
..x.......
|
||||
.x@@@.....
|
||||
..@@@@....
|
||||
...@@@@...
|
||||
..x@@@@@..
|
||||
...@.@.@@.
|
||||
..x@@.@@@x
|
||||
...@@@@@@.
|
||||
....@@@...
|
||||
|
||||
Remove 2 rolls of paper:
|
||||
..........
|
||||
..........
|
||||
..x@@.....
|
||||
..@@@@....
|
||||
...@@@@...
|
||||
...@@@@@..
|
||||
...@.@.@@.
|
||||
...@@.@@@.
|
||||
...@@@@@x.
|
||||
....@@@...
|
||||
|
||||
Remove 1 roll of paper:
|
||||
..........
|
||||
..........
|
||||
...@@.....
|
||||
..x@@@....
|
||||
...@@@@...
|
||||
...@@@@@..
|
||||
...@.@.@@.
|
||||
...@@.@@@.
|
||||
...@@@@@..
|
||||
....@@@...
|
||||
|
||||
Remove 1 roll of paper:
|
||||
..........
|
||||
..........
|
||||
...x@.....
|
||||
...@@@....
|
||||
...@@@@...
|
||||
...@@@@@..
|
||||
...@.@.@@.
|
||||
...@@.@@@.
|
||||
...@@@@@..
|
||||
....@@@...
|
||||
|
||||
Remove 1 roll of paper:
|
||||
..........
|
||||
..........
|
||||
....x.....
|
||||
...@@@....
|
||||
...@@@@...
|
||||
...@@@@@..
|
||||
...@.@.@@.
|
||||
...@@.@@@.
|
||||
...@@@@@..
|
||||
....@@@...
|
||||
|
||||
Remove 1 roll of paper:
|
||||
..........
|
||||
..........
|
||||
..........
|
||||
...x@@....
|
||||
...@@@@...
|
||||
...@@@@@..
|
||||
...@.@.@@.
|
||||
...@@.@@@.
|
||||
...@@@@@..
|
||||
....@@@...
|
||||
|
||||
Stop once no more rolls of paper are accessible by a forklift. In this
|
||||
example, a total of 43 rolls of paper can be removed.
|
||||
|
||||
Start with your original diagram. How many rolls of paper in total can be
|
||||
removed by the Elves and their forklifts?
|
||||
|
||||
Your puzzle answer was 8493.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: **
|
||||
|
||||
At this point, you should [16]return to your Advent calendar and try
|
||||
another puzzle.
|
||||
|
||||
If you still want to see it, you can [17]get your puzzle input.
|
||||
|
||||
References
|
||||
|
||||
Visible links
|
||||
1. https://adventofcode.com/
|
||||
2. https://adventofcode.com/2025/about
|
||||
3. https://adventofcode.com/2025/events
|
||||
4. https://adventofcode.com/2025/shop
|
||||
5. https://adventofcode.com/2025/settings
|
||||
6. https://adventofcode.com/2025/auth/logout
|
||||
7. Advent of Code Supporter
|
||||
https://adventofcode.com/2025/support
|
||||
8. https://adventofcode.com/2025
|
||||
9. https://adventofcode.com/2025
|
||||
10. https://adventofcode.com/2025/support
|
||||
11. https://adventofcode.com/2025/sponsors
|
||||
12. https://adventofcode.com/2025/leaderboard/private
|
||||
13. https://adventofcode.com/2025/stats
|
||||
14. https://adventofcode.com/2025/sponsors
|
||||
15. https://adventofcode.com/2025/sponsors/redirect?url=https%3A%2F%2Fcoderabbit%2Elink%2Fadventofcode
|
||||
16. https://adventofcode.com/2025
|
||||
17. https://adventofcode.com/2025/day/4/input
|
||||
20. javascript:void(0);
|
||||
Reference in New Issue
Block a user