Discussion thread for day 15 of the Advent of Code - https://adventofcode.com/2024/day/15
I'm happy to use Alteryx even in the weekend.
REGEX_Replace([Concat_Object], "(^.*#[^#]*?)(\.?)(O*@)$", "$1$3$2")​
(EDIT)
Optimized my WF for Part2: 7minutes. I could not make it faster any more.
My solution.
It takes about 7min.
In P1 I focused on the map and in P2 I focused on the object.
Day15. More in spoiler
This one was a bit of a beast... happy to have managed to get almost all of it done while riding shotgun for two long car rides yesterday as well... and special shoutout to my fiancé for driving and letting me work on Advent of Code.
Part 1 I approached essentially the exact same way I did Day 6 part 1 (for one time through at least with that guard it ran fairly quickly so thought I would try that route again). Part 2 (once the new grid was prepped) I handled two different ways. For horizontal movement I treated it the same way as part 1, for vertical movement I decided to focus in on the objects in the path and used an additional nested iterative macro to do the checks for surrounding "big box" pieces and walls they might run into.
This took way longer than I hoped it would. I kept constantly crashing into bugs that were often trivial to fix, but difficult to find. I built a mechanism to capture all states of the map, and generated a video file to watch the robot on its route in the sample data to make sure nothing weird was happening... But that's all behind me now. No fancy algorithms, just good old fashioned brute force (with limited optimizations as well):
Finally, solved!
This is the one of the most difficult puzzle this year for me.
it difficult to find where the bug. it worked in sample but not the input.
Day15P2 was one of the most challenging problems to solve in this year’s AoC.
In P1, there were 20,000 loops, and initially, history was maitained, which caused errors in Alteryx. The box positions were swapped using regular expressions, but the processing in P1 was somewhat redundant.
For P2, I gave up reusing P1 and decided to rebuild it from scratch. After considerable thought, I referred to @Tokimatsu 's workflow for inspiration. By representing only the left side of "O" and "#" as representative points without actually increasing the "O" and "#", significant simplification was achieved.
First, a mapping table was created in Excel by drawing a diagram of which range of cells would be affected when "@ or O" moved. When "@ moved, the influence range of the pushed cells were calculated. If there was a #" within the range, the move was canceled; if there was no "#", a macro updated the positions of "@ and O".P1 took about 10 minutes to execute, and P2 took about 8 minutes.<P1 Macro><P2 Macro to check the pushed cell><P2 Main Macro>
Solved!
I was able to get a working solution for Part 1, but it took ~3 hours to run. While it was running, I looked through the posts here and saw @gawa's RegEx witchcraft and redid my Part 1 macro with his technique. I initially tried to just do one Generate Rows regardless of the direction, which worked, but then in the next step, I ended up with double the tools, compared to Gawa. I did the 2nd Generate Rows which then made everything else downstream much simpler.
For Part 2, I initially tried to do it by naming the boxes 1 and 2 instead of [ and ], to try to still be able to use some of Gawa's fancy RegEx - it worked for the small example but not for the larger example. I also tried to just have a value for the left side of the box and blank for the right side, but that turned into a mess. Eventually, I went back to a version of what I did for my 3 hour part 1, with a lot of support from Gawa's part 2 when I kept getting stuck (THANK YOU!) and finally got something that works. It takes 3.5 hours to run, but, hey, I'm calling it a victory
I also misread part 2 and thought it was saying the GPS was from where ever the nearest corner of the building was, vs the newest corner of the box but always from the top left. So I initially added in more logic than needed and was very confused
Part 1 completed. This was a very different challenge than I've done before (and this is my most successful year to date as far as feeling good with my solutions.
Haven't tackled part 2 yet.