Sliding Tile Puzzle and Maze Generator with Solver
Slide numbered tiles into order, or create a perfect maze, walk it with arrow keys and reveal the shortest route.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Pick a puzzle
Sliding or maze.
- 2Choose the size
Tiles or maze dimensions.
- 3Play
Click or use arrow keys.
- 4Check progress
Blue tiles or step count.
- 5Solve or print
Show path or download PNG.
About this tool
Two classic puzzles share this page. The sliding tile puzzle, made famous as the 15-puzzle in the 1870s, has numbered tiles in a frame with one gap; you slide tiles into the gap until they are in order. The maze generator draws a new random maze every time, lets you walk it with the arrow keys, and shows the shortest route from start to finish. Both are good for quick breaks, for teaching logic and algorithms, and for making printable activities.
Sliding puzzle
Choose 3 × 3 (the 8-puzzle), 4 × 4 (the 15-puzzle) or 5 × 5. Click a tile in the same row or column as the gap to slide it, or use the arrow keys. Tiles already in their final place turn blue, so you can see progress. Moves and time are counted, and your fewest moves for each size are kept in this browser.
Why every shuffle is solvable
Exactly half of all arrangements of a sliding puzzle can be solved. Johnson and Story proved in 1879 that solvability depends on the parity of the arrangement: for odd widths, the number of inversions (pairs of tiles in the wrong order) must be even; for even widths, the inversions plus the gap's row counted from the bottom must be odd. The famous prize puzzle with only 14 and 15 swapped can never be solved. Every shuffle here is checked before you start.
A method that always works
1. Solve the top row, placing the last two tiles of the row together. 2. Solve the next row the same way, until two rows remain. 3. Solve the bottom two rows column by column from the left, placing each pair together. This is slower than expert methods but never gets stuck.
Maze generator
Choose a width and height and press New maze. Mazes are made by a randomised depth-first search, a method that removes walls while wandering until every square has been visited. The result is a perfect maze: exactly one route joins any two squares, with no loops. Move the blue dot from the green start to the red exit with the arrow keys.
Shortest path
Tick "Show shortest path" to draw the route found by breadth-first search, which explores squares in order of distance and therefore finds the shortest path. In a perfect maze the shortest path is also the only one. The step counts let you compare your walk with the best.
Printing
Download the maze as a PNG to print for children, puzzle sheets or classroom activities. Turn the solution on or off before downloading to make a puzzle and its answer key.
## In the classroom Both puzzles show how computers search: the maze solver explores outwards one step at a time, and the solvability rule shows how parity proves something impossible without trying every move.
Limits
Very large mazes are easier to use on a big screen. Everything runs in your browser; this is a puzzle for fun, not a formal assessment.
Worked example
A 4 × 4 shuffle with an odd number of inversions plus the blank's row from the bottom is solvable.
Quick facts
- Category: Games & Fun
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in English.
- Content last reviewed:
- Official source: Sliding puzzle solvability by permutation parity (Johnson and Story, 1879); mazes by randomised depth-first search, solved by breadth-first search
Frequently asked questions
Can every sliding puzzle be solved?
Only half of arrangements; every shuffle here is checked.
How do I move tiles?
Click a tile in line with the gap, or use the arrow keys.
What is a perfect maze?
A maze with exactly one route between any two squares.
How is the shortest path found?
By breadth-first search.
Can I print a maze?
Yes, download it as a PNG.
Is anything stored?
Only your best move counts, in this browser.
