Skip Navigation

[2023 day 10] part 2 seemed too hard so I visualized part 1 instead

I wanted to show how the maze follows from individual letters but it was way too large

4

You're viewing a single thread.

4 comments
  • There is a really simple approach that I describe in my comment on the megathread, but it's always good to have a nice visualisation so thanks for sharing!

    • Counting line crossings? I'm not sure what that means

      • Imagine you're looking at a grid with your path drawn out on it. On any given row, start from the left and move right, cell by cell. You're outside the area enclosed by your path at the start of the row. As you move across that row, you remain outside it until you meet and cross the line made by your path. Every non-path cell you now pass can be added to your 'inside' count, until you next cross your path, when you stop counting until you cross the path again, and so on.

        In this problem, you can tell you're crossing the path when you encounter one of:

        • a '|'
        • a 'F' (followed by 0 or more '-'s) followed by 'J'
        • a 'L' (followed by 0 or more '-'s) followed by '7'

        If you encounter an 'F' (followed by 0 or more '-'s) followed by '7', you've actually just skimmed along the line and not actually crossed it. Same for the 'L'/ 'J' pair.

        Try it out by hand on the example grids and you should get the hang of the logic.

        • Ah I see, I'll go back and try once I have some extra time. Thanks.