Sliding Puzzle — 15-Puzzle Game
Play the classic 15-puzzle: slide tiles into order. Solvable shuffles only.
How to play
- Click any tile adjacent to the blank space to slide it into the gap.
- Arrange tiles 1–15 in order left-to-right, top-to-bottom, blank in bottom-right.
- Use arrow keys to slide tiles: the arrow points the direction the tile moves.
- Click 'New Game' to generate a fresh, guaranteed-solvable shuffle.
Slide tiles into numerical order (1–15). Use arrow keys or click tiles. Only solvable positions are generated.
How it works
The Sliding Puzzle (15-Puzzle) consists of a 4x4 grid with 15 numbered tiles and one blank space. Tiles adjacent to the blank space can slide into it. The goal is to slide the tiles from a shuffled arrangement into the correct numerical order: 1 through 15 reading left to right, top to bottom, with the blank in the bottom-right corner.
The puzzle is only solvable for exactly half of all possible shuffled positions. This implementation guarantees every dealt shuffle is solvable, so a solution always exists.
The standard solving approach works in layers: first place tiles 1, 2, 3, 4 in the top row, then place tiles 5, 6, 7, 8 in the second row, and so on downward. The bottom-right 2x2 section (tiles 13, 14, 15 and blank) can be solved with a known four-step rotation sequence. Special L-shaped maneuvers handle placing tiles 3 and 4 together at the end of the top row without disturbing tiles already placed.
The 15-Puzzle is one of the most famous combinatorial puzzles in history, popularized in the 1880s. A solution in under 60 moves is considered expert-level play.
Worked example
Placing tile 1 into the top-left corner
- Locate tile 1 anywhere on the board.
- Slide the blank space adjacent to tile 1 without disturbing any already-solved tiles.
- Slide tile 1 one step closer to the top-left corner by moving the blank to the other side of tile 1.
- Repeat: maneuver the blank around tile 1, then slide tile 1 one step further toward the goal.
- Once tile 1 reaches the top-left corner, proceed to place tile 2 without moving tile 1.
Tile 1 is correctly placed in position (row 1, col 1) and remains there for the rest of the solve.
Common mistakes to avoid
- Moving a tile into its correct position early, then accidentally dislodging it while placing a later tile in the same row.
- Trying to solve the entire bottom row simultaneously instead of placing tiles row by row in order.
- Forgetting that the last two tiles in a row require a special rotation maneuver and attempting to slide them in directly, which always displaces one of them.
Key terms
- Blank space
- The empty cell that allows adjacent tiles to slide; every move slides one tile into the blank.
- Solvable position
- A shuffled arrangement that can be transformed into the solved state; exactly half of all arrangements are solvable.
- Layer solving
- A solving strategy that places tiles row by row from top to bottom, ensuring completed rows are not disturbed.
Frequently asked questions
- How do I win?
- Arrange tiles 1–15 left-to-right, top-to-bottom with the blank in the bottom-right corner.
- Can every shuffle be solved?
- No — exactly half of all permutations are unsolvable. This game only generates solvable ones.