Slide Puzzle Solver

5x5 Sliding Puzzle Solver

Fast, complete solutions for the 24 puzzle — solved layer by layer.

Click a cell and type its number. Use arrows to focus, Backspace to clear, Enter to solve. Separate two-digit tiles with a space.

Solvable

Inversions: 0 (counting out-of-order nonblank pairs); an even count is required for an odd-width board.

Example: a solution for this board

131354209819102126151118127162314222417
Initial example board. Follow every move below to reach the solved position.

120 moves · Not guaranteed shortest

Steps 1–10

  1. Step 1: Move 23 down
  2. Step 2: Move 11 down
  3. Step 3: Move 10 down
  4. Step 4: Move 19 right
  5. Step 5: Move 8 right
  6. Step 6: Move 9 right
  7. Step 7: Move 2 up
  8. Step 8: Move 6 left
  9. Step 9: Move 9 down
  10. Step 10: Move 13 down

Steps 11–20

  1. Step 11: Move 3 right
  2. Step 12: Move 2 up
  3. Step 13: Move 13 left
  4. Step 14: Move 8 left
  5. Step 15: Move 5 down
  6. Step 16: Move 4 left
  7. Step 17: Move 19 up
  8. Step 18: Move 10 up
  9. Step 19: Move 15 right
  10. Step 20: Move 5 down

Steps 21–30

  1. Step 21: Move 10 left
  2. Step 22: Move 19 down
  3. Step 23: Move 4 right
  4. Step 24: Move 10 up
  5. Step 25: Move 5 up
  6. Step 26: Move 15 left
  7. Step 27: Move 19 down
  8. Step 28: Move 5 right
  9. Step 29: Move 10 down
  10. Step 30: Move 4 left

Steps 31–40

  1. Step 31: Move 5 up
  2. Step 32: Move 10 right
  3. Step 33: Move 8 right
  4. Step 34: Move 13 right
  5. Step 35: Move 6 up
  6. Step 36: Move 21 right
  7. Step 37: Move 20 down
  8. Step 38: Move 6 left
  9. Step 39: Move 21 up
  10. Step 40: Move 12 up

Steps 41–50

  1. Step 41: Move 7 left
  2. Step 42: Move 16 left
  3. Step 43: Move 11 left
  4. Step 44: Move 19 down
  5. Step 45: Move 15 right
  6. Step 46: Move 11 up
  7. Step 47: Move 16 right
  8. Step 48: Move 9 down
  9. Step 49: Move 11 left
  10. Step 50: Move 8 down

Steps 51–60

  1. Step 51: Move 13 right
  2. Step 52: Move 21 right
  3. Step 53: Move 12 up
  4. Step 54: Move 11 left
  5. Step 55: Move 9 up
  6. Step 56: Move 7 right
  7. Step 57: Move 18 right
  8. Step 58: Move 20 down
  9. Step 59: Move 11 left
  10. Step 60: Move 9 left

Steps 61–70

  1. Step 61: Move 21 down
  2. Step 62: Move 12 right
  3. Step 63: Move 9 up
  4. Step 64: Move 18 up
  5. Step 65: Move 7 left
  6. Step 66: Move 16 left
  7. Step 67: Move 17 up
  8. Step 68: Move 24 right
  9. Step 69: Move 16 down
  10. Step 70: Move 21 down

Steps 71–80

  1. Step 71: Move 18 right
  2. Step 72: Move 7 up
  3. Step 73: Move 22 up
  4. Step 74: Move 16 left
  5. Step 75: Move 21 down
  6. Step 76: Move 22 right
  7. Step 77: Move 20 right
  8. Step 78: Move 14 up
  9. Step 79: Move 16 left
  10. Step 80: Move 21 left

Steps 81–90

  1. Step 81: Move 22 down
  2. Step 82: Move 20 right
  3. Step 83: Move 14 right
  4. Step 84: Move 16 up
  5. Step 85: Move 21 left
  6. Step 86: Move 14 down
  7. Step 87: Move 20 left
  8. Step 88: Move 17 left
  9. Step 89: Move 24 up
  10. Step 90: Move 22 right

Steps 91–100

  1. Step 91: Move 17 down
  2. Step 92: Move 20 right
  3. Step 93: Move 14 up
  4. Step 94: Move 17 left
  5. Step 95: Move 22 left
  6. Step 96: Move 23 left
  7. Step 97: Move 19 down
  8. Step 98: Move 24 right
  9. Step 99: Move 20 right
  10. Step 100: Move 14 right

Steps 101–110

  1. Step 101: Move 17 up
  2. Step 102: Move 22 left
  3. Step 103: Move 23 left
  4. Step 104: Move 19 left
  5. Step 105: Move 24 down
  6. Step 106: Move 20 right
  7. Step 107: Move 14 right
  8. Step 108: Move 18 down
  9. Step 109: Move 12 down
  10. Step 110: Move 9 right

Steps 111–120

  1. Step 111: Move 7 up
  2. Step 112: Move 12 left
  3. Step 113: Move 8 left
  4. Step 114: Move 13 down
  5. Step 115: Move 9 right
  6. Step 116: Move 8 up
  7. Step 117: Move 13 left
  8. Step 118: Move 14 up
  9. Step 119: Move 19 up
  10. Step 120: Move 24 left

Why 5x5 solutions aren’t the shortest

Before you press Solve, it helps to know what kind of answer a 5x5 sliding puzzle solver can give. A 5x5 board has about 7.8 septillion solvable positions, a number with 25 digits. Finding the provably shortest route through a space that size takes far more computing time than a web page can reasonably spend. Even the exact maximum number of moves a 5x5 can need is unknown: nobody knows it.

So this solver makes a different promise. It always gives you a complete, correct solution that takes your board all the way to 1–24 with the blank in the bottom-right corner, and it gives it to you fast. It does not promise that the solution is the shortest possible, and the result says “not guaranteed shortest” next to the move count, so you always know which kind of answer you have.

For a puzzle you are stuck on, that is usually the trade you want: a reliable list of moves now, rather than a perfect one that never arrives.

How the 5x5 sliding puzzle solver works, layer by layer

The solver shrinks the 24 puzzle one layer at a time, the same way a person would:

  1. Top row. Tiles 1 to 5 go into place. The last two tiles of the row are brought in together so the finished tiles never have to be disturbed.
  2. Left column. Tiles 6, 11, 16 and 21 go into place, again finishing with a pair.
  3. The rest is a 4x4. What remains in the bottom-right is a 4x4 puzzle. It goes to the same 4x4 solver used for the 15 puzzle, which finishes the job.

Once a tile is placed in its layer, the solver never moves it again. That is what makes the method dependable: every step makes permanent progress. It is also why the total isn’t the shortest, since the first row and column are fixed before the rest of the board is considered.

If you would like to solve a big board yourself, the same layers work by hand; how to solve a sliding puzzle shows the pair trick with diagrams.

Parity on a 5x5 board

Before solving, the tool checks whether your board can be solved at all. Exactly half of all 5x5 arrangements can’t be. Because 5 is an odd width, the rule is short: read the tiles left to right, top to bottom, skipping the blank, and count the pairs where a larger number comes before a smaller one. An even count means solvable; an odd count means impossible. Where the blank sits doesn’t matter.

123456789101112131415161718192021222423
Only 23 and 24 are swapped: one inversion, an odd count, so this 5x5 board can't be solved.

Swapping any two tiles other than the blank flips the answer, so a board like the one above becomes solvable as soon as 23 and 24 trade places. Most of the time, though, an “impossible” result means a tile was entered wrong. The unsolvable sliding puzzle page explains the rule in more depth.

Frequently asked questions

Why isn't the 5x5 solution the shortest?

Because proving a 5x5 solution is the shortest would take far too long in a browser. The board has about 7.8 septillion solvable positions. Instead, the solver uses the layer-by-layer method, which always produces a complete and correct solution quickly, and it labels the result as not guaranteed shortest so you know what you are getting.

What is the 24 puzzle?

The 24 puzzle is the 5x5 sliding puzzle: twenty-four numbered tiles and one empty square. You slide tiles into the gap until they read 1 to 24 in order, with the blank in the bottom-right corner. It is the bigger sibling of the 15 puzzle and follows exactly the same rules.

How many moves does a 5x5 sliding puzzle take?

It depends on the board, and nobody knows the exact maximum for a 5x5. The solver tells you the number of moves in its solution for your board. Because 5x5 solutions are not guaranteed shortest, a shorter route may exist, but every move in the list is correct and leads to the solved board.

Can I upload a picture of my 5x5 puzzle?

Yes. Open the upload panel, choose 5x5 and Numbers or Picture mode, then add a screenshot or photo. Drag the four corners to frame the board, check the tiles the tool reads, fix any that are wrong, and press Solve. The image is processed in your browser and never uploaded.