Discussion thread for day 4 of the Advent of Code - https://adventofcode.com/2025/day/4
Got my hopes up when I saw the input to this problem, thinking it would be some sort of maze solve... alas, it was much simpler than that. Can't believe we are already 1/3 of the way through AoC 😭.
Very simple.
Every time when I see map style puzzle in AoC, I'm always overwhelmed at first according to past experience(unlike @Hub119 😁)
However, today's puzzle was very straightforward without having to come up with something clever.
Ah, 1/3 is already over this year...
Part1
The context of puzzle was simple, and everything was smooth but my answer was wrong at the end. Thing is that, I didn't realize the presence of rolls that have no
neighborhood in any of 8 surrounding position. Count of those presence were missing, that takes extra time to reach to the goal.
Part2
Nothing special. The solution for part1 is applicable to part2. Just iterating process where I felt it's too straightforward....
In my twisted assumption, usual part2 would ask...
"when roll paper is removed, new roll papers will be generated at surrounding 8 position." or input data is so designed that only one roll paper is removed in one iteration that require huge iterations.
Anyway, just for fun, I created visual map how rolls have been removed.
Yellow: Remained rolls after all iteration
Blue: Removed during iteration (concentration depends on iteration number in which roll was removed)
Another day, another AoC BaseA challenge! Today's puzzle was certainly not the most challenging one I have faced thus far, however it does feel good to be able to finish with a good time and with no assistance whatsoever (no blogs, solution peeking, or asking neighbors at work😂). That being said, I now have nearly the full 24 hours to wait until the next one😢
My solutions:
The macro used in Part 2
My reflection:
Almost repeating the first part's logic and iterating it for second partOverall, a good challenge.
Another simple problem! Made a macro this time. Macro-less is potentially possible, but I do not want to deal with that headache.
Happy Solving, y'all!
Edit: I made the edit that I referred to above to optimize the macro portion of my solution. Looks much cleaner now:
I solved it using the Spatial tools.
My solution!
I almost lost my way. Except for it, it is not difficult. And I use some macros which I created last year for mapping problem. It works well.
Start to use back macros created in previous years.
Everyone is so fast.
The grids are back! For those of us who've participated in previous years, this is pretty much our bread and butter now, though today was definitely a very kind challenge compared to others! Workflow/macro aren't as clean as they could be but I was more than pleased with everything working first time.
I went route 1 today
By far my favourite challenge so far!
Some very elegant solutions out there. Had to go down the macro route for Part 2 for reasons of sanity.
Day 4
Shout out to @Carolyn - I have my first "Nope didn't work" container. We're supposed to be keeping those? Kinda glad I did because I went back later to figure out why it didn't work and of course it was a rookie mistake. Learning so much!
My overall strategy for Pt 1:
Then for Pt 2
Thanks for the tip on the zero counts @Hub119 !
That was a good one.
Nice to see the return of grids, always appreciate doing part 1 while fretting about what part 2 could be.
This time, it was relatively kind.
Pleasantly surprised to find the multi-row formula tool goes all the way up.
Expected an error message along the lines of "138 is to many what the ^&## are you doing?"
Observations and tips
Whenever we're going to count something (In this case, adjacencies) I like to convert that thing from text representation into 1/0 so that we can do math to it later. In this case, it let me use a single multi-row to do the check by adding all 8 adjacent values together rather than making them 8 tests for "@".
Keeping your data orderly, which may involve turning off the AMP engine, often lets you shortcut. In this case, by keeping Row/Column sort we can know the index of any given adjacency.
Most of the complexity in this one is dealing with the (literal) edge cases. Wrote conditionals for Column and Row at Max and Min values. The other way to do this is to pad the grid with a row and a column of 0 values. In this case the conditionals were fairly clean so I didn't pad but there is value in taking complexity out of your formulas and putting it on the canvas.
It helps to think about the boundaries of a problem. We have in the past, and likely will again this year, seen problems that are either unbounded or at the minimum geometric. Those are the ones that will burn your computer down and require extreme macro optimization. pruning or formula trickery. This is not that. You're removing at least 1 crate every iteration, which means the problem is in N time with respect to the number of locations (actually the number of crates, which you can count or just estimate density and round up.)
With upper bound of <20k and with a high density estimate of 10k your macro should run in reasonable time (Minute and a half for mine, as an example.) If it doesn't, try to figure out why, because you will need the space(time) for future problems.
As a bonus, a bounded problem means you don't have to do an end state for the macro, which I find to be the most awkward part of iterative design. You can just run 10k times knowing that the last few thousand will likely be adding 0.
Final, with the Macro pasted in.
Working with numbers means I get to skip a few steps relative to some of the other Macro versions.
I almost severely overcomplicated this one! Reminder to read the prompt before assuming what they are going to ask
This was a fun one!
Had to build a multi-field-multi-row formula to get my method to work out dynamically:
And as much as I wanted to do something different, for part 2 I just wrapped it all in an iterative macro where I rebuilt the grid without the removed rolls each time:
How are you going to cope when its over in a few days? Finish the whiskey advent calendar? Maybe we should design our own crazy puzzles for next year.
Made it with 30min to spare for the day. Yes, yes, I know it doesn't actually have to be done on the same day, but the likelihood of me staying on task is heavily reliant on me not falling behind 😂
Anyway, here it is, in all it's glory:
This one was much easier than yesterday's and a lot of fun.
Love any excuse to use iterative macros (which part 2 provided)
It was a straightforward problem.
That one was finding itself easy until.... I was certain I was right, but of course I was forgetting the zeros.
Part one took a little tweaking, but once I had that one solved, I basically had the exact steps needed for the part two macro!
2 Stars again!
This one was fun!