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

  • @mykl
    link
    11 year ago

    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!

      • @mykl
        link
        3
        edit-2
        1 year ago

        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.