PlayNook

Work it out

Is my sliding puzzle solvable?

Type in the arrangement you are stuck on. Half of all scrambles cannot be solved at all, you cannot tell which by looking, and no amount of sliding will change it.

Board15 puzzle

Click a square and type. Space marks the gap, Backspace clears.

Enter the whole board first

  • 16 squares still empty.

How the solvability checker works

A wooden sliding puzzle on a desk beside two badges reading solvable and unsolvable, and a notepad with an inversion count worked out

You give it a board; it gives you a verdict and the arithmetic behind it. There is nothing hidden in between, so here is exactly what happens between the two.

1. You type the arrangement in

Pick 3×3, 4×4 or 5×5, click the first square, and type. The cursor moves on by itself, so a 15 puzzle takes about fifteen seconds. Two-digit numbers work as you would expect — type 1 then 2 and you get 12. Press space on the empty square to mark the gap, Backspace to clear one, and the arrow keys to move around. On a phone there is a number pad under the grid instead.

2. It refuses to answer an incomplete board

If a square is still empty, or you have typed the same number twice, or there is no gap, it says so and gives no verdict. That is deliberate. A checker that confidently answers a board you mistyped is worse than no checker: you would walk away with a judgement about a puzzle that is not the one on your table.

3. It counts the inversions and reads the gap’s row

Those two numbers are all it needs. It shows both, and the total where the total is what matters, so you can follow the reasoning rather than take it on faith — and check your own arithmetic against it next time.

4. If the answer is no, it names the two tiles that fix it

Any single exchange of two tiles moves an arrangement to the other side of the divide. The checker highlights a pair and will swap them for you at the press of a button, so you can watch the verdict flip while nothing else about the board changes. That is the whole proof in one click.

If the answer is yes, there is a link that hands the exact arrangement to the playable puzzle so you can try it without typing it again.

How to check a sliding puzzle by hand

The checker is faster, but the rule is short enough to do on paper, and it works at any board size.

Counting inversions

Read the tiles in order — left to right, top row first, then the next row — and write them out as a single list, ignoring the gap entirely. An inversion is any pair in that list where a larger number comes before a smaller one. They do not have to be next to each other. Count them all.

Sam Loyd's 14-15 board with the count worked out: one inversion, blank in row one from the bottom, total two, even — and it has to be odd

The board above is the famous one. Reading it out gives 1, 2, 3 … 12, 13, 15, 14 — a list in perfect order except that 15 arrives before 14. That is exactly one inversion.

The rule, by board width

  • Odd number of columns — 3×3, 5×5, 7×7. Solvable if the inversion count is even. The gap’s position does not matter at all.
  • Even number of columns — 4×4, 6×6. Add the row the gap is in, counted from the bottom, starting at 1. The total has to be odd.

That second line is where most explanations go astray. Some count the gap’s row from the top; some leave the board width out altogether. Either mistake produces the right answer about half the time — which is indistinguishable from a rule that works, and is why the wrong versions have survived so long.

Why half of all arrangements are impossible

Two 4x4 boards side by side, identical except that two tiles have swapped places; one is labelled solvable and the other never solvable

Watch what a single slide does. Move a tile sideways and the reading order is unchanged — the inversion count does not move at all. Move a tile vertically and it jumps over the tiles in between, changing the inversion count by an odd number — but the gap has also changed row.

So on an even-width board, inversions plus the gap’s row is either untouched or changed by two. Its parity— whether it is odd or even — can never change. On an odd-width board the same argument leaves the inversion count’s parity fixed on its own.

A quantity the rules cannot change is called an invariant, and this is one of the tidiest in recreational mathematics. The solved board carries one value of it. Every arrangement carrying the other value is in a separate world, and no route between the two worlds exists. Not a hard route — no route.

What to do with an impossible puzzle

Swap any two tiles. One exchange flips the parity and moves the whole arrangement across the divide, and it is the only kind of fix there is.

On a physical puzzle that means popping two tiles out of the frame and putting them back the other way round. Most plastic ones let you do it by flexing the tray slightly at one corner. Once you have done it, every scramble you produce by sliding will be solvable forever after — you cannot fall back to the wrong side by accident.

It is also, almost always, how the puzzle got broken in the first place: somebody took the tiles out to clean it, or a child did, and they went back in a different order.

The 14-15 puzzle and the $1,000 that was never paid

In the 1880s Sam Loyd offered a thousand dollars to anyone who could solve a board that was complete except for the 14 and the 15 being the wrong way round. It became a craze; people worked at it for weeks.

The arrangement has one inversion, the gap sits in row 1 from the bottom, and 1 + 1 = 2 is even — the wrong side of the line on a four-wide board. Johnson and Story had published the proof in 1879, before the prize was ever offered. Loyd was in no danger at any point.

He also claimed for the rest of his life to have invented the puzzle. He had not: that was Noyes Palmer Chapman, a postmaster in New York state, around 1874. The claim went unchallenged for over a century until Slocum and Sonneveld traced the real history in 2006. What Loyd invented was the impossible version and the prize that made it famous — which, as marketing, is hard to fault.

How we know the rule is right

We did not take it from anywhere; we checked it. On the 3×3 there are only 362,880 arrangements, so every one can be tested. Walk outwards from the solved board and note every arrangement that can be reached: it comes to 181,440 — exactly half. Then compare the rule against that list, arrangement by arrangement.

It agreed on all 362,880.

The same walk answers a second question nobody usually asks: the hardest 3×3 arrangement is 31 moves from solved, and there are exactly two of them. For the 4×4 the equivalent figure is 80 moves, which took a dedicated computation in 2010 — that one is not ours and we have not repeated it.

Frequently asked questions

How do I know if my sliding puzzle is solvable? Count the inversions — every pair of tiles that appears in the wrong order when you read the board row by row, ignoring the gap. On a board with an odd number of columns (3×3, 5×5) the arrangement is solvable if that count is even. On a board with an even number of columns (4×4) add the row the gap is in, counted from the bottom starting at 1, and the total has to be odd. The checker on this page does exactly that as you type, and shows you the count.

Why can half of all arrangements never be solved? Because every legal slide leaves one quantity untouched. Move a tile sideways and the inversion count does not change at all; move one vertically and it changes by an odd number, but the gap also changes row — so the combination of the two stays as it was. A quantity the rules cannot change is called an invariant. The solved board has one value of it, and every arrangement carrying the other value sits in a separate world you can never slide into.

My puzzle is stuck with the last two tiles swapped. What now? That is the classic symptom, and it means the arrangement was on the wrong side of the divide from the start — usually because somebody once prised the tiles out and pushed them back in a different order. No sequence of slides will fix it. Take any two tiles out and swap them and the whole puzzle becomes solvable; the checker highlights a pair for you.

Does this work for the 8 puzzle and the 24 puzzle too? Yes. The checker handles 3×3, 4×4 and 5×5 and applies the right version of the rule automatically. The wrinkle is that on a board with an odd number of columns the gap's row does not matter at all, while on an even one it does — which is why a rule someone half-remembers from a 4×4 gives wrong answers on a 3×3.

How accurate is this? We checked it exhaustively on the 3×3, where that is possible. There are 362,880 ways to arrange those tiles; we walked outwards from the solved board to find every arrangement that can actually be reached — 181,440 of them, exactly half — and compared the rule against that list. It agreed on all 362,880. The checker also uses the same code as the playable puzzle on this site, so the two cannot give different answers to the same board.

Is a picture sliding puzzle different? Only in one respect. If the tiles carry a picture rather than numbers, and that picture has rotational symmetry or repeated areas, more than one arrangement can count as finished — which can make a technically unsolvable numbering look solvable to the eye. For a numbered puzzle, or any picture with a single correct layout, the rule here is the whole story.

Can I make an unsolvable puzzle solvable without taking it apart? No. That is the point of an invariant: sliding cannot change it, so no sequence of moves however long will help. The only fix is to physically exchange two tiles. On a plastic puzzle that means popping two out and putting them back the other way round.

Who worked this out? Johnson and Story, in 1879, within a few years of the puzzle appearing. Sam Loyd then offered $1,000 for a solution to an arrangement he knew to be on the wrong side — the famous 14-15 puzzle, which has one inversion and the gap in row 1, giving an even total on a four-wide board. The prize was never in any danger.

Games built on the same idea

A rule that settles a puzzle before you start playing it is not a spoiler — it is the interesting part. Every game in our maths and logic collection works that way, with the theory visible on screen while you play.

More tools: everything we have built, including boards and sheets to print.