Fifteen Puzzle
Slide numbered tiles into order on grids from 2x2 to 12x12. Every shuffle is checked to be solvable, with a move counter and timer for each attempt.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Fifteen Puzzle?
The Fifteen Puzzle is a square tray of numbered tiles with one gap. Click a tile next to the gap and it slides in. The goal is to put the tiles back in order, 1 to 15 reading left to right and top to bottom, with the gap in the bottom-right corner. The default board is the classic 4 by 4, and the Grid Size menu goes from a 2 by 2 warm-up (three tiles) to a 12 by 12 marathon with 143 tiles.
Each new game shuffles the tiles and checks the arrangement with the standard parity test, so every board you are given can actually be solved. The counter shows moves and elapsed time, and the timer stops the moment the last tile lands. Shuffle reshuffles the current board for a 5 move penalty; Restart deals a fresh board with the counters at zero.
It runs in your browser and saves nothing: a reload deals a new puzzle.
- Grid sizes from 2x2 (3 tiles) to 12x12 (143 tiles)
- Every shuffle checked solvable with the inversion-parity test
- Move counter and timer that stops when solved
- Shuffle with a 5 move penalty and instant Restart
- Runs in your browser with no sign-up
Updated
How to use the Fifteen Puzzle
- Choose a Grid Size (start with 3x3 or 4x4). A new shuffled board appears.
- Click any tile directly above, below, left or right of the gap to slide it into the gap.
- Solve the top row first, then the next, until two rows remain; finish the last two rows column by column from the left.
- Use Shuffle to remix the board (adds 5 moves) or Restart for a fresh board with zeroed counters.
- When the last tile is in place, the Status badge shows Completed with your moves and time.
Background and insight
The puzzle was made in the United States in the 1870s and became a craze in 1880, with newspapers offering prizes for impossible positions. Sam Loyd later claimed to have invented it and promoted a $1,000 prize for swapping just the 14 and 15. Nobody could win, because in 1879 William Johnson and William Story had already proved that exactly half of all arrangements cannot be reached from the solved position.
The test is about parity. Count inversions: pairs of tiles where a larger number comes before a smaller one in reading order. With the gap in the bottom-right corner, a board is solvable only if that count is even. Each slide changes the count in a way that preserves the combined parity of the inversions and the gap's row, so an odd-inversion board with the gap in the corner can never be fixed. A random shuffle lands on the wrong half half of the time, which is why a puzzle game has to check.
Exhaustive computer searches have shown that every solvable 4 by 4 position can be solved in at most 80 single-tile moves. Humans use a layer method instead and typically need 150 to 300.
Common use cases
Learning a systematic method
The 3x3 board is small enough to learn the row-by-row method in a few minutes.
Timed challenges
The move counter and timer give two scores to beat on each grid size.
Teaching parity
A hands-on way to show students why half of all arrangements are impossible.
A long, calm session
A 10x10 or 12x12 board takes a long time and rewards patience more than speed.
Tips and limitations
- Never try to place tiles in strict number order across the last two rows. Finish the top rows first, then solve the bottom two rows one column pair at a time.
- Place the last two tiles of a row together: park the last one under its target, slide the second-last in, then rotate both into place.
- Larger boards are the same method repeated. A 6x6 is a 4x4 once you have solved two rows and two columns.
- Shuffle costs 5 moves, so it never helps your move count.
- There is no keyboard control; click or tap the tiles.
Sources and further reading
- Notes on the "15" Puzzle, American Journal of Mathematics. Johnson and Story, 1879: the proof that half the arrangements are unreachable
- A Modern Treatment of the 15 Puzzle, The American Mathematical Monthly. Archer, 1999: the parity argument in full
- The parallel search bench ZRAM and its applications, Annals of Operations Research. Brüngger and colleagues, 1999: every position solvable in 80 moves
- A087725: maximal number of moves for the n x n sliding puzzle, OEIS Foundation. God's number for 3 by 3 and 4 by 4 boards
Frequently asked questions
Is every Fifteen Puzzle shuffle solvable?
Yes. After shuffling, the game counts inversions and, if the count is odd, swaps two tiles so the board lands in the solvable half. With the gap in the bottom-right corner, an even inversion count means solvable on every grid size. The game also re-deals if a shuffle happens to come out already solved.
Why is the 14-15 swap impossible in the 15 puzzle?
Swapping two tiles while everything else stays put changes the inversion count by one, making it odd. Every legal slide keeps the combined parity of inversions and the gap's row unchanged, so no sequence of moves can produce a single swap. Johnson and Story proved this in 1879.
What is the easiest way to solve the 15 puzzle?
Solve the top row, then the second row, each by placing the first tiles directly and the last two as a pair. Then solve the last two rows one column at a time from the left: 9 and 13 together, then 10 and 14, then cycle 11, 12 and 15 into place. The how-to guide walks through each step.
What is the fewest moves needed to solve a 4x4 sliding puzzle?
Any solvable 4x4 position can be solved in at most 80 single-tile moves, a bound established by exhaustive computer search. Finding an optimal solution for a given board needs a program; a good human solve with the layer method usually takes a few hundred moves.
Does the Shuffle button reset my moves and timer?
Shuffle keeps your move count and adds a 5 move penalty, but it restarts the timer. Restart deals a completely new board and sets both moves and time back to zero, so use Restart when you want a clean attempt.
Is there an in-depth guide to the Fifteen Puzzle?
Yes. “How to Solve the 15 Puzzle: A Row-by-Row Method” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.