The locked row maze starts at S and ends at R. Do not cross a wall; there is exactly one route.
A good maze makes you feel that the answer is one turn away. A good database investigation can feel that way too, although I do not recommend drawing the latter as a maze when somebody is waiting for a fix. Today we can enjoy the first kind.
Start in the cell marked S at the upper left. Finish at R near the lower right. Move one cell at a time, up, down, left or right. You may not cross a dark wall, and diagonal moves do not count. Trace with a finger if you like. The maze was generated as a connected tree of cells, which means there is one route between any two cells. This is not a trick with an invisible doorway.
A shortcut that seems to cross a line probably does. Give yourself a minute and keep moving. The answer below lists the moves so you can check the result even if you are reading on a small screen.

The Locked Row Maze Answer
The route from S is: right, down, left, down, right, down, down, down, right, up, up, right, down, right, right, down. The final move reaches R. If you left out one of the two upward steps, you probably ran into the central wall.
The generator opens one wall each time it adds a new cell to the maze. It never opens a second route back into a visited cell. That construction makes the maze a tree, and a tree has one path between S and R. I also ran a solver over the finished grid instead of trusting the picture by eye.
The little connection to SQL is about not forcing a path because it looks shortest. An optimizer can only choose among paths allowed by the data and available access methods. Our drawn wall is far simpler than a real plan, but it makes the difference between a wish and a possible route visible.
If you solved it with a finger, good. If you solved it by marking dead ends, also good. There is no prize for pretending you saw the whole path at once.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.
Discover more from SQL Authority with Pinal Dave
Subscribe to get the latest posts sent to your email.

