Skip to the page
Explorable Illusions

See for yourself — then run it 100,000 times.

15 Puzzle: With 14 and 15 Swapped, No Solution Exists

Explorable Illusions · Published

Swap tiles 14 and 15, and no amount of sliding will put them back. William Woolsey Johnson proved why in the American Journal of Mathematics in 1879: once the gap is back in its corner, the tiles can only have been swapped an even number of times, and 14 for 15 is one swap. In a second note in the same journal, William E. Story showed that every layout on the other side of that count can be solved. So exactly half of all 15 puzzle layouts have a solution.

Protocol · 4 parts
Two 4 by 4 boards: solved, and the same with 14 and 15 swapped; the solved total is odd, the swapped total is even.

Open the diagram full size

The solved box and the same box with 14 and 15 swapped. Below each board: pairs out of order plus the row of the gap, counted from the bottom."15 puzzle: solved, and with 14 and 15 swapped" by Explorable Illusions — https://explorableillusions.com/math-toys/15-puzzle/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

At a glance

Name
15 puzzle
Also called
The 14-15 puzzle (the name Sam Loyd's book, printed in 1914, says it became known by)
First recorded
Earliest source read for this page: William Woolsey Johnson and William E. Story, 1879, two notes in the American Journal of Mathematics. Johnson wrote that the puzzle had recently been exercising many persons in Baltimore, Philadelphia and elsewhere. Who made the first one is not settled by the sources read here.
Type
Sliding-block puzzle: 15 numbered tiles and one gap in a 4 x 4 box
Main explanations
Proof, not a competing theory: with the gap back in its corner, the tiles can only have been swapped an even number of times, so a layout one swap away from solved can never be solved (Johnson 1879, chessboard argument). Every layout of the other kind can be solved (Story 1879). So exactly half of all layouts are solvable. The test used on this page for the 4 x 4 box (pairs out of order + row of the gap from the bottom) sorts layouts the same way. On boards with an odd number of columns the gap's row drops out and an even count of pairs out of order means solvable. This page's program checked both forms on four smaller boards.
On this page
Static figures and recomputable data: the parity count for five layouts, exhaustive searches of four small boards (exactly half reachable on each), and replayed slide sequences for the solvable layouts

15-puzzle-glance.csv (CSV) · what the file holds and its license

Look at the right-hand board. On this page, the gasp point is one number you can count yourself. The solved box has 0 pairs out of order, and the swapped box has 1.

Why can't 14 and 15 be swapped back?

Johnson put the common belief plainly on page 397: “It seems to be generally supposed, by those who have tried the puzzle, that this is always possible … but this is an error.” His proof takes about a page.

A 4 by 4 board colored like a chessboard; the gap loops through four squares and returns to its corner after 4 slides.

Open the diagram full size

Color the board like a chessboard. The gap changes color with every slide, so a gap that ends where it started has made an even number of slides."The gap changes color with every slide" by Explorable Illusions — https://explorableillusions.com/math-toys/15-puzzle/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

Color the squares like a chessboard. Every slide moves the gap to a square of the other color, so a gap that comes home to its corner has made an even number of slides. Because each slide trades the gap with one tile, the tiles have then been swapped an even number of times.

The last step is about swaps in general. Johnson showed that an order made with an odd number of swaps can never also be made with an even number. Swapping 14 and 15 takes one swap, which is odd, so no series of slides can produce it or undo it. As with the Seven Bridges of Königsberg, a count settles the question before anyone tries a single route.

How can you tell if a 15 puzzle is solvable?

The same idea gives a test you can run on any 4 x 4 layout in a minute.

  1. Read the tiles row by row from the top left, and skip the gap.
  2. Count the pairs out of order: a bigger number read before a smaller one.
  3. Find the row of the gap, counting from the bottom row as 1.
  4. Add the two numbers: an odd total means solvable, and an even total means no solution exists.
A mixed 4 by 4 layout read row by row: 49 pairs out of order, gap in row 2 from the bottom, total 51.

Open the diagram full size

A mixed layout: 49 pairs out of order plus the gap in row 2 makes 51, an odd total."Counting pairs out of order on a mixed 15 puzzle" by Explorable Illusions — https://explorableillusions.com/math-toys/15-puzzle/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

For this layout the total is 51, so the test says solvable, and the program then searched for a way to solve it and found one of 63 slides. It replayed every slide to confirm that the box ends solved, though 63 is not claimed to be the shortest possible sequence. On a board with an odd number of columns, such as 3 x 3, the gap's row drops out of the test, and an even number of pairs out of order means solvable.

Story's note states its test in a different reading order, snaking left to right and then back. This page's program checked the row-by-row test against every layout of four smaller boards and found no disagreement. As with the Monty Hall problem, the answer turns on a rule the picture does not show: here, that every slide is a swap with the gap.

Exactly half: the 1879 proof

Johnson's proof rules out every layout of the wrong parity, which is half of them, and Story's note proves that the other half can always be solved. On page 402 he concludes “that every arrangement whose order is positive, and only such, can be converted into the standard arrangement.”

Bars for 2x2, 2x3, 3x3, 2x4 and 4x4 boards: on each, exactly half of all layouts can be reached from the solved one.

Open the diagram full size

Exhaustive searches on four small boards, and the 4 x 4 count that follows from the 1879 proof."Exactly half of all layouts are reachable" by Explorable Illusions — https://explorableillusions.com/math-toys/15-puzzle/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The full 4 x 4 box has 16! = 20,922,789,888,000 ways to place 15 tiles and a gap, far too many to list one by one, so the proof carries the count: 10,461,394,944,000 of them are solvable, exactly half. The program checked the same split where listing is possible. On the 3 x 3 board, starting from the solved layout, it reached 181,440 of the 362,880 layouts, and every one it reached passed the parity test.

On the 4 x 4 board, the program made 1,000,000 random legal slides from the solved box and another 1,000,000 from the 14-15 box, with fixed seeds. The parity of the total never changed once in either walk. As with the Mandelbrot set, one rule sorts every case into in or out, and here every case of the small boards could be listed.

What was the 1880 craze?

Johnson opened his note by saying the puzzle “has recently been exercising the ingenuity of many persons in Baltimore, Philadelphia and elsewhere.” A postscript on page 399 adds that it had since appeared as a square box of 15 blocks, where the task was simply to “move the blocks until in regular order.” In a note at the foot of page 404, the journal's editors wrote that the puzzle may safely be said to have engaged the attention of “nine out of ten persons of both sexes and of all ages and conditions of the community.” That is their estimate, not a count.

Cartoon: a man holds his head beside a box of numbered blocks with politicians' heads, marked THE “BOSS” PUZZLE
Puck, 17 March 1880: James Albert Wales drew the 1880 presidential race as a sliding-block puzzle. Grant is block 15, Sherman 14 and Blaine 13."15-14-13. The great presidential puzzle (Puck, 1880)" by James Albert Wales — https://commons.wikimedia.org/wiki/File:15-14-13._The_great_presidential_puzzle_-_J.A._Wales._LCCN2007684705.jpg — Public domain (US: published 1880 in Puck; EU: artist James Albert Wales d. 1886, per the Library of Congress catalog); modified: cropped to the printed picture, removing the album page and the printed title, publisher and lithographer lines below it; scaled to 1600 px wide

The magazine Puck turned the craze into politics. Its cartoon by James Albert Wales puts candidates' heads on numbered blocks in a box marked THE “BOSS” PUZZLE, with one empty square for sliding.

Sam Loyd later tied the puzzle to himself. The Cyclopedia of Puzzles published under his name in 1914, three years after his death, says on page 235 that “in the early seventies” he drove the world crazy with it. The same page offers the 14-15 layout and says “A prize of $1,000, which was offered for the first correct solution to the problem, has never been claimed.”

Under the sliding rules, the count above means no one could have claimed it. Loyd's date does not sit easily with Johnson's “recently” in 1879, and the sources read for this page do not settle who made the first box. The same page also sets a harder task: slide the blocks into a magic square whose lines add to 30.

Check it yourself

Every row below comes from the program. Totals use pairs out of order plus the gap's row from the bottom; a solvable verdict comes with a replayed slide sequence.

LayoutPairs out of orderGap row from bottomTotalVerdict
Solved011 (odd)solved
14 and 15 swapped112 (even)no solution
12–13 and 14–15 swapped213 (odd)solved in 26 slides
Numbers in order, gap upper left (Loyd's Fig. 2)044 (even)cannot reach solved; reached from the 14-15 box in 48 slides
Worked example above49251 (odd)solved in 63 slides

Download the layout checks (CSV) · what the file holds and its license

BoardAll layoutsReachable from solvedShareHow checked
2 x 224121/2every layout searched
2 x 37203601/2every layout searched
3 x 3362,880181,4401/2every layout searched
2 x 440,32020,1601/2every layout searched
4 x 420,922,789,888,00010,461,394,944,0001/21879 proof

Download the board counts (CSV) · what the file holds and its license

Now break it

Keep the 14-15 box, and change one thing: swap a second pair.

Board with only 14 and 15 swapped: 1 pair out of order, total 2, even, no solution.

Open the diagram full size

Before: only 14 and 15 swapped. One pair out of order plus row 1 gives 2, an even total."One pair swapped: no solution" by Explorable Illusions — https://explorableillusions.com/math-toys/15-puzzle/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
Board with 12 and 13 and 14 and 15 both swapped: 2 pairs out of order, total 3, odd, solvable.

Open the diagram full size

After: 12 and 13 swapped as well. Two pairs out of order plus row 1 gives 3, an odd total."Two pairs swapped: solvable again" by Explorable Illusions — https://explorableillusions.com/math-toys/15-puzzle/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

Swap 12 and 13 too, and the box is solvable again: the program found a 26-slide solution and replayed it. Or keep the 14-15 box and change the goal instead. Loyd's second problem asks for the numbers in order with the gap in the upper left, and that layout has an even total too, so it is in the same half. The program reached it from the 14-15 box in 48 slides.

Try this next: Seven Bridges of Königsberg — a walk across seven bridges that a count rules out before you take a step.

Sources

  1. William Woolsey Johnson and William E. Story, “Notes on the ‘15’ Puzzle,” American Journal of Mathematics 2 (1879): 397–404. https://archive.org/details/sim_american-journal-of-mathematics_1879_2Read: pages 397–399, page 402 and the closing page of the notes, checked against the page images
  2. James Albert Wales, “15-14-13. The great presidential puzzle,” Puck 7, no. 158 (17 March 1880): 32; Library of Congress Prints and Photographs Division, ppmsca.15782. https://commons.wikimedia.org/wiki/File:15-14-13._The_great_presidential_puzzle_-_J.A._Wales._LCCN2007684705.jpgRead: file page with the Library of Congress catalog details, and the full-size image
  3. Sam Loyd, Sam Loyd's Cyclopedia of 5000 Puzzles, Tricks, and Conundrums With Answers (1914). https://archive.org/details/CyclopediaOfPuzzlesLoydRead: page 235, checked against the page image

Cite this page

Explorable Illusions. (2026). 15 Puzzle: With 14 and 15 Swapped, No Solution Exists. Explorable Illusions. Published 2026-11-13. https://explorableillusions.com/math-toys/15-puzzle/

Add the date you read it. Figures and CSV files on this page are CC BY 4.0 unless their credit line says otherwise.

How pages here are checked Corrections log Report an error: contact@explorableillusions.com

More in Puzzles, Fractals & Math Toys

  • Dark heart-shaped body with a round bulb on its left, ringed by purple and green bands.
    Puzzles, Fractals & Math Toys

    Mandelbrot Set: Exact Area Still Unknown as of 2026

    Square, add c, repeat: the Mandelbrot set is every point that never escapes. As of 2026 its exact area is unknown; grid counts put it near 1.51.

    Picture credit

    "The Mandelbrot set, full view" by Explorable Illusions — https://explorableillusions.com/math-toys/mandelbrot-set/ — CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • Hand-drawn 17th-century map of a walled city with a river splitting into two branches around an island.
    Puzzles, Fractals & Math Toys

    Seven Bridges of Königsberg: No Walk Crosses Each Once

    The seven bridges of Königsberg join four lands that touch 5, 3, 3 and 3 bridges. See why no walk crosses each bridge once, and why dropping any one fixes it.

    Picture credit

    "Topographia Practica – 3. Regiomontum (Königsberg)" by Fryderyk Getkant — https://commons.wikimedia.org/wiki/File:Topographia_Practica_-_3._Regiomontum.jpg — Public domain (US: hand-drawn map made 1634–39 by an author who died in 1666, public domain whether counted as published (before 1931) or unpublished (life plus 70 years); EU: author d. 1666, more than 70 years ago); modified: scaled from 7,544 to 1,600 px wide; no crop, no colour change

  • Engraved 4 by 4 grid of numbers on a wall: 16 3 2 13, 5 10 11 8, 9 6 7 12, and 4 15 14 1.
    Puzzles, Fractals & Math Toys

    Magic Square: 1514 Sits in Dürer’s Bottom Row

    Every row, column and diagonal of Dürer's 1514 magic square adds to 34, and its bottom row has 15 14 in the middle. See the 86 sets of four and the 880 count.

    Picture credit

    "Melencolia I (detail: the magic square)" by Albrecht Dürer — https://commons.wikimedia.org/wiki/File:Albrecht_D%C3%BCrer,_Melencolia_I,_1514,_NGA_6640.jpg — CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/); modified: cropped to a 4:3 frame around the whole magic square with a strip of the wall, the foot of the bell, part of the rope and the edge of the hourglass frame; scaled to 1,200 x 900 px