Sliding Puzzle

A sliding puzzle is a square frame of numbered tiles with one cell left empty. Slide tiles into that gap until the numbers read in order, left to right and top to bottom, with the gap at the bottom right. Exactly half of all arrangements can never be sorted, no matter how long you push — so every deal here is checked against the parity rule first, and only a solvable one is ever handed to you.

Moves0Home2/15Time0:00Best—Puzzle#1

New puzzle deals a fresh frame at the size you last chose — only ever one that can be solved — Undo walks back the last 40 slides — a line push is one of them however many tiles it carried — and Hint lights up one tile to slide. A tile in line with the gap takes every tile between them along with it, and each tile that moves counts one move. The three-dot menu holds the 3 × 3, 4 × 4 and 5 × 5 frames, today’s shared puzzle and the solve-it-for-me helper.

Your statistics · 4 × 4

Played
0
Won
0
Win rate
0%
Streak
0
Best streak
0
Best time
—
Fewest moves
—

A puzzle is recorded when it ends — sorted, abandoned for another, or handed to the helper. Only a frame you sorted without help counts as a win, so the fewest-moves record is your own.

This frame

Fifteen tiles and 10,461,394,944,000 reachable arrangements. Ten and a half trillion positions is far past what a search in a browser tab could hold, so the helper solves this frame the way a person does — top row, left column, then the last 3 × 3 corner exactly, averaging 84 moves.

Every deal is a pure function of its number, so puzzle #1 is the same arrangement on any device — and it is dealt from the solvable half of the arrangements, never the other one.

Keyboard

Arrows
Slide a tile that way
U
Undo one move
H
Hint
N
New puzzle
Esc
Stop the helper
F
Full screen
Frames
3 × 3, 4 × 4, 5 × 5
Tiles
8, 15 or 24
Unsolvable deals
None, ever
Hardest 3 × 3
31 moves

How do you solve a sliding puzzle?

By shrinking the frame. Finish the top row and never touch it again, then the left column of what is left, and repeat — each pass turns an n × n puzzle into a smaller one, until a 3 × 3 corner is all that remains and you can simply see the end. Trying to place tiles in number order across the whole frame instead is the usual mistake: tile 6 goes home, then tile 7 arrives and has to push 6 out of the way to get past it.

  1. 1Fill the top row, left to rightPlace every tile of the row except the last two, one at a time, and treat each finished cell as a wall you never move through again.
  2. 2Place the last two of the row togetherPut the second-to-last tile in the CORNER cell and the last tile directly below it, then rotate them both into place with two slides. Placing them one at a time deadlocks — see below.
  3. 3Do the same down the left columnSame method rotated a quarter turn: all but the bottom two, then the bottom two staged and rotated together.
  4. 4Alternate until a 3 × 3 corner is leftA 4 × 4 frame becomes a 3 × 4, then a 3 × 3. A 5 × 5 takes two more passes to get there.
  5. 5Finish the cornerEight tiles in nine cells is small enough to solve by eye, and small enough that this page solves it by exhaustive search — so the hint there is a proven shortest move.

Why can half of all sliding puzzle arrangements never be solved?

Because a slide cannot change a certain quantity, and the finished frame has a particular value of it. Count the inversions: pairs of tiles that are out of order when you read the frame like a book, ignoring the gap. A sideways slide changes nothing at all. A vertical slide jumps one tile over the n − 1 tiles in between, which flips the inversion count by an odd amount on an even-width frame and an even amount on an odd-width one — and it also moves the gap one row.

  • Odd width (3 × 3, 5 × 5) — solvable exactly when the inversion count is even.
  • Even width (4 × 4) — solvable exactly when the inversions plus the gap's row counted up from the bottom come to an odd number.
  • Either way — the arrangements split into two equal halves, and no slide crosses between them.

This board does not take that rule on trust. A 2 × 2 frame has 24 arrangements; a search from the solved frame reaches exactly 12 of them, and they are exactly the 12 the rule accepts. A 3 × 3 frame has 362,880 arrangements; the same search reaches exactly 181,440, and again the rule and the search agree on every one. Only arrangements from the reachable half are ever dealt here.

The famous consequence: take a finished frame and swap just the last two tiles. One transposition flips the parity, so that arrangement is now in the unreachable half and nobody will ever sort it. That exact position was the prize puzzle of the fifteen-tile craze of 1880, and the reason none of the prizes was ever paid: Johnson and Story had already published the proof in the American Journal of Mathematics in December 1879, a few months before the first advertisement went up.

How many moves does a sliding puzzle take?

The three frames, measured on this engine
FrameTilesSolvable arrangementsSolver's route
3 × 38181,44022 moves, and shortest
4 × 41510,461,394,944,00084 moves on average
5 × 5247,755,605,021,665,492,992,000,000197 moves on average

Those route lengths are this page's own solver, measured across the first 1,000 deals of each frame: it averages 84 moves on the 4 × 4 frame and never needed more than 118, and averages 197 on the 5 × 5 frame with a worst case of 258. A move is one tile moving one cell — pushing a line of three counts three — so those figures are directly comparable with a person's move counter.

The shortest possible solution is a different question. On the 3 × 3 frame the answer is known exactly, because all 181,440 positions fit in memory: the average position is 21.97 moves from home, and precisely two positions in the whole space need 31, which is the worst there is. On the fifteen-tile frame the equivalent figure is 80 moves, established by Korf and Schultze's exhaustive search in 2005 — a computation that took a cluster, not a browser tab.

Can a computer find the shortest solution on every frame?

On the 3 × 3 frame, yes, and this page does it. A breadth-first search from the finished frame reaches all 181,440 positions and stores the exact distance of each in a table of 362,880 bytes, so the hint gives a genuine shortest move and the optional counter beside it is the true number of moves you still need.

On the 4 × 4 frame, no — and this is the honest part. There are 10,461,394,944,000 reachable positions, and holding one byte for each would need ten terabytes. So the solver here does not search: it places tiles row by row and column by column, exactly as the method above describes, and finishes the last 3 × 3 corner with the exact table. What it plays out always solves the puzzle, and it is never claimed to be the shortest route. On 5 × 5 the space is 7,755,605,021,665,492,992,000,000 positions and the same applies with more room to spare.

What do the controls do on this board?

  • Click or tap a tile in line with the gap. A tile three cells away takes the two between it and the gap along with it, and the counter goes up by three.
  • Arrow keys slide a tile in the direction of the arrow — up moves the tile below the gap upwards. Every legal move on the frame is one of those four keys.
  • Undo walks back the last 40 slides — a line push is one of them, however many tiles it carried, so forty entries can be a good deal more than forty moves — and Hint lights up one tile to slide next.
  • Solve it for me plays a full solution out a move at a time, and Escape stops it. A puzzle the helper has played a move on is recorded as unsolved, so the fewest-moves record stays your own.
  • Nothing is ever removed from the frame and no move is illegal in a way that loses the game: a sliding puzzle cannot be made unwinnable by playing it badly.

If you like the shrinking-frame idea, 2048 is the same board with the opposite problem — every move pushes every tile at once — and block puzzle asks you to clear lines rather than sort them. For pure deduction on a grid, try nonogram.

How do you get better at sliding puzzle?

  • Finish a row, then treat it as a wallThe whole method rests on never disturbing what is done. Once the top row is home, work only in the rows below it; the puzzle you are left with is genuinely smaller, which is what makes progress possible at all.
  • Place the last two tiles of a row togetherPut the second-to-last tile in the corner cell and the last one directly below it, then rotate both home with two slides. Placing the second-to-last tile directly on its home cell is the classic deadlock: it blocks the only route the last tile has.
  • Stop taking rows while three of them still remainRows alone do not finish the job, and this is why: freeze a row and the cell directly below its left-hand end has one free neighbour left. The gap can only reach that cell through the one beside it, pushing whatever sits there out — and it can only leave the same way, pulling the tile straight back. Alternate a row with a column so you land on a 3 × 3 block instead, which has room to turn in and is small enough to finish by eye.
  • Park the gap on the far side of the tile you want to moveA tile travels one cell per move and only towards the gap, so the gap has to arrive on the correct side before anything useful happens. Plan the gap's path and the tile's together rather than chasing the tile and hoping: that is exactly what this page's helper does, and it is why its routes average 84 moves on the fifteen-tile frame rather than wandering into the hundreds.
  • Use a line push when the whole row is already rightPushing three tiles at once costs three moves, the same as three separate slides, but it costs one click and no thought. Use it to travel; use single slides when the order inside the line matters.

Sliding Puzzle questions people ask

Is every sliding puzzle solvable?
No — exactly half of all arrangements cannot be sorted, whatever you do. Every deal on this page is checked against the parity rule before it appears, so the ones you are given always can be.
Can you get stuck in a sliding puzzle?
Not permanently. Every slide is reversible, so a solvable frame stays solvable no matter how badly you play it. You can lose your place, but you can never lose the puzzle.
Does pushing three tiles at once count as one move or three?
Three, here. Each tile that moves one cell counts one, which keeps the counter comparable with a shortest solution and keeps the fewest-moves record meaningful.
What is the hardest sliding puzzle position?
On the 3 × 3 frame, exactly two of the 181,440 positions need 31 moves, and the average is 21.97. On the fifteen-tile frame the worst case is 80 moves, found by exhaustive search in 2005.
How do you play a sliding puzzle with a keyboard?
The four arrow keys slide a tile in that direction — up slides the tile below the gap upwards. U undoes, H hints, N deals a new puzzle and F goes full screen.

The rules in six lines

  1. 1Read the frameA square frame holds numbered tiles and one empty cell. A 3 × 3 frame holds eight tiles, a 4 × 4 holds fifteen and a 5 × 5 holds twenty-four.
  2. 2Slide a tile into the gapOnly a tile orthogonally next to the empty cell can move, and it moves into that cell. Tiles are never lifted, rotated or removed.
  3. 3Push a whole line at onceClicking a tile further along the gap's own row or column slides every tile between them one cell. Each tile that moves counts as one move.
  4. 4Sort the numbers into reading orderThe puzzle is finished when the tiles read 1, 2, 3 and so on left to right and top to bottom, with the empty cell at the bottom right.
  5. 5Only a solvable frame is dealtHalf of all arrangements cannot be sorted. Every deal here is tested against the inversion-parity rule and repaired if it falls in the wrong half.
  6. 6Nothing can be lostThere is no way to make a solvable frame unsolvable by playing, so there is no losing move — only longer and shorter routes home.

The long version, with worked examples and the questions beginners actually ask, is on how to play sliding puzzle.

Put Sliding Puzzle on your own site

The board runs in an iframe with no tracking, no cookies and no sign-up. Paste this wherever you want it. See all the embeddable games for the rest.

<iframe src="https://www.cardgamenook.com/embed/sliding-puzzle" width="100%" height="620" style="border:0;border-radius:10px;max-width:900px" title="Sliding Puzzle — free online" loading="lazy"></iframe>
<p style="font:14px system-ui;margin:6px 0 0"><a href="https://www.cardgamenook.com/sliding-puzzle">Play Sliding Puzzle</a> at Card Game Nook</p>