# JonMark Perry's Grid Logic Puzzle

Consider the following puzzle type proposed by JonMark Perry.

Start with a square grid of arrows, each one pointing in one of the four cardinal directions. For example:

You start at the top left. You travel 1 step in the direction of the arrow you are on. Continue until you reach the bottom right.

Only there's a 'twist' - when you leave an arrow, it rotates 90° clockwise.

edited from JMP's original "1 or 2 steps" for simplicity of the problem

Let's try to analyse this puzzle!

## Is it always solvable, regardless of the initial setup of arrows in the grid? If not, are there conditions for when it is solvable? Does the answer vary according to the size of the grid?

Disclaimer: I don't know the answer to this question, and nor, it seems, does JMP himself.

• What is the puzzle here? It seems like you don't have a choice at all (?) Jan 13 '17 at 3:09
• What happens if you the arrow forces you to go off the edge? Jan 13 '17 at 4:36
• For the sake of fun, could we look at this puzzle with it wrapping around the board? So that an arrow sending us over the top sends us to the bottom instead of "to our inevitable doom" :) Jan 13 '17 at 13:19
• I don't see how it's a puzzle or how it's solvable or not when you take away the choice. Jan 13 '17 at 14:36
• @NeilW The interesting thing then becomes the specific layout of arrows, rather than the (non-)choice of moves once you're given the arrows. Jan 13 '17 at 14:44

No it's not always solvable... consider

all arrows pointing upwards. Then you keep going upwards until you 'fall off' i.e run out of room. As for solvability, I have no idea for simple conditions. For grid size, case bash small grids maybe?

I'll post here as I investigate.

If it's impossible in a particular configuration, then that implies the arrows eventually either lead "outside" too early (for example, if all the arrows point to the same direction, the route eventally just leads out of the edge) or we end up on the same certain squares over and over.

From the start of this "quasi-loop" (always ending up on the same squares even if there's seemingly no pattern to it) that may or may not be an actual loop, the area consisting of the included squares must have some corner or edge squares, which can't be surrounded by all the adjacent squares in the vertical and horizontal directions, thus only allowing fewer than 4 travels through them. Likewise, all their orthogonal neighbours must only be reached finite times, because otherwise they lead to the edge squares infinite times, so we finally reach the conclusion that no square can be reached infinite times, creating a contradiction. That means such a QL is impossible, but a non-bottom right square can still lead you outside (a configuration is solvable as long as it doesn't allow for the latter).

Bonus: If the board wraps,

... then we can rule out leaving the grid and apply the same conclusions about QLs, which means it's always solvable. Sorry, no luck @Piotr Pytlik.

• Awwwwww :( that's a shame. Although on first thought it does seem like it wouldn't be possible for you to flip arrows and not leave a certain area. I think a "reach-area" argument could be used, that if in some steps you have a boundary, then visiting the boundary flips the arrows and progressively makes the boundary bigger, until you finally reach all the squares on the board. Also interesting :) Jan 15 '17 at 21:37

As to the question of Is it always solvable -

obviously not,

because

in the given example, you don't leave the top-left 4x4 square before running into the left wall.

(This part is not an answer)

I'd like to see what happens when we add the possibility that

walking off walls moves you to the other side of the board.

Then

the death by walking off would not exist,

but I don't know if it's always possible to reach the goal square.

EDIT - Seems to me like wrapping the sides of the board would be a little boring, because that would make the start and finish squares only 2 squares apart, and would require some playing around to guarantee you're not going to stumble into the finishing square pretty quickly.

Honestly maybe this question should just boil down to - is it possible to create a board (with wrapping edges) on which you have an infinite loop which does not walk along all of the squares.

For a grid of any size there are trivial examples where one reaches the bottom right corner, and trivial examples where one doesn't.

If the top left arrow points up you're off the grid immediately.

If all the arrows of the rightmost column point down and the top row of all columns bar the rightmost point right, you'll clearly reach the bottom right corner.

Supposing we're dealing with a randomly filled grid, or all possible fillings of a grid (same thing), then

You'd be more likely to complete the journey if

the start and end points were not boundary points.

Beyond a certain size, the bigger the grid, the more likely you are to leave the grid before hitting the bottom right corner. (Your target is getting probabilistically smaller as your exit point).