Solver & solutions

Sliding Puzzle Solver — Solve Any 3×3, 4×4 or 5×5 Board Online

Enter your board, press Solve, get the shortest sequence of moves — free, in the browser, no upload. Below the tool: the six algorithms a sliding puzzle solver can run on, and which one this solver actually uses.

Updated 2026-07-27 8 min read

Sliding puzzle solver

Press Shuffle for a random board, or Edit to enter your own. Solve plays the moves step by step. 3×3 solutions are optimal.

How to use the solver

The tool above solves any solvable 3×3, 4×4 or 5×5 board optimally — the answer it returns is the shortest possible move sequence, not just a working one.

  1. Press Edit and enter your board: number the tiles as they should read in the finished puzzle (top-left is 1), and place them where they currently sit. Solving a picture puzzle — from a game, a photo app, a wooden toy? Mentally number the finished image top-left to bottom-right first.
  2. Press Solve. The move list appears instantly for 3×3 boards and within moments for 4×4.
  3. Play the moves back on your real puzzle, one at a time.

If the solver says the board is unsolvable, that is not a bug — exactly half of all arrangements can never be solved, and no sequence of legal moves will fix them. Prefer to learn the technique instead of reading out moves? The human method is here.

How a sliding puzzle solver works — six algorithms compared

If you are implementing a sliding puzzle solver and are not sure which algorithm to use, the rest of this article compares six well-known ones across speed, memory, code complexity, and the board size they comfortably handle. The answers are different for the 3×3, the 4×4, and the 5×5.

1. Breadth-first search (BFS)

The dumbest correct algorithm. Explore states level by level until you find the goal.

2. A* with Manhattan distance

The first real algorithm. Same structure as BFS but states are popped from a priority queue ordered by f = g + h, where h is the Manhattan distance heuristic.

3. A* with Manhattan + linear conflict

Add 2 moves to the heuristic for every pair of tiles in the same row that are both in their goal row but in the wrong order (similarly for columns). They will need to pass each other, which Manhattan distance cannot see.

4. IDA* with Manhattan + linear conflict

Iterative-deepening A*. Do depth-limited DFS using f-cost as the depth measure, raising the limit each iteration. Trades memory for time by re-exploring.

5. IDA* with walking distance

Walking distance is a tighter heuristic. Precompute, for each tile arrangement projected onto rows only, the minimum number of row-swap operations to put each tile in its correct row. Same for columns. Add.

It captures something Manhattan misses: tiles in the same row "fighting" for the same slot.

6. IDA* with additive disjoint pattern databases

The strongest known heuristic for sliding puzzles. Partition the tiles into disjoint groups (a common 15-puzzle partition is 7+8, or 5+5+5). Precompute, for each group, the cost of permuting the group's tiles to their goal positions over all possible arrangements of that group. At search time, look up each group's contribution and sum.

Summary recommendations

If you are writing a solver today:

What about machine learning?

A reasonable question in 2026. Neural network heuristics have been studied since at least 2014 and can produce fast heuristics for sliding puzzles. The catch is that they are typically not admissible — they can overestimate, which means the resulting algorithm is no longer guaranteed to be optimal. For app developers who want guaranteed-optimal solutions for difficulty calibration, classical pattern databases remain the right tool.

For research interest, pattern databases trained by a neural network produce slight speedups on the hardest 15-puzzle instances. Useful for academic papers, marginal for shipping software.

What goes in a real app

A shipping mobile app that needs a solver for hint generation almost always lands on:

That is the right pragmatic stack for a calm phone app. Slide Puzzle's hint button works exactly this way.