Unable to load image

rDrama Advent of Code Day 21: Home stretch Edition

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

22
Jump in the discussion.

No email address required.

I was late to start and just got to part 2. I noticed that there is an empty column and row surrounding the starting point in the input so you know the fastest way to get to a 'clone' map. And that the border of the grid is empty. But my head hurts trying to work out what to do with that information

Jump in the discussion.

No email address required.

im gonna try to just have it literally go back like if x==X, set x=0

i just have to change the counter for steps to be inline instead of counting 'O' post-run

Jump in the discussion.

No email address required.

Each time you add a new "border" of grids around the existing grid(s), how does the answer change?

Jump in the discussion.

No email address required.

From part 1 you would have worked out that you can only finish on cells that take an even number of steps to get to.

The empty middle row/column and diamond means that you always know the minimum steps and entry position to get to the next grid copy. The odd/even pattern continues into the next grid, so if the top-middle point in the original grid was an even number of steps, the bottom-middle point in the grid above it will be an odd number of steps.

So, because the border is also empty, we also know the minimum amount of steps to any cell in the grid because the fastest way will always be via our fast entry point. Which means that the pattern will be identical to the original grid, but inverted every 2nd copy (+1 = inverted, +2 = original, +3 = inverted etc)

So we can just work out the original and inverted grid once and apply that a bunch of times. The confusing part for me happens when you start getting to the very end of your step count because you won't be able to fill an entire grid. I guess you can run your pathfinding algorithm from your starting point into the edge grid

Jump in the discussion.

No email address required.

Minor spoilers:

https://i.rdrama.net/images/17031815100767343.webp

Jump in the discussion.

No email address required.

There's a much easier way to solve pt 2 (if you know this one little trick that I didn't but saw on the subreddit)

Jump in the discussion.

No email address required.

:marseyspit: Holy shit it fricking works

Jump in the discussion.

No email address required.

you won't be able to fill an entire grid

:#marseysurejan:

I think Eric made it so you do fill your outer grids. The grid width is a multiple of the number of steps.

Jump in the discussion.

No email address required.

You reach the far border of the outermost garden, but only for your starting row/col. Everything else is a triangle-ish partial fill, and working those out is why part 2 is such a pain.

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/1701695785632276.webp

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.