Exercise: Shuffled 2D Mazes

Learn to render a 2D maze by shuffling the rows and drawing them in random orders.

Point to ponder

The top-down floorplan we've used for 2D mazes is an intuitive way to display them, but it's not the only way. In fact, we can make the puzzle much harder to solve simply by changing how we render it. What if we were to turn a 2D maze into a sequence of shuffled 1D grids?

Problem statement

Render a 2D maze by shuffling the rows and drawing them in random order. Assign each row a random color, and then indicate north/south connections between cells by drawing small circles of the appropriate colors in each cell.

Here's an example. Suppose we generated the following 5x5 maze:

Get hands-on with 1400+ tech skills courses.