Search for a tool
15-Puzzle Solver

Tool/Solver to instantly resolve a 4x4 puzzle, check the solvability of a configuration, and display the puzzle's solving steps.

Results

15-Puzzle Solver -

Tag(s) : Number Games, Board Games

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best '15-Puzzle Solver' tool for free! Thank you!

15-Puzzle Solver

15-Puzzle Solver

Loading...
(if this message do not disappear, try to refresh this page)




See also: Magic Square

15-Puzzle Generator




Answers to Questions (FAQ)

What is a 15 puzzle? (Definition)

A 15-puzzle is a 4x4 sliding puzzle game consisting of a 16-square grid (4 rows Ă— 4 columns) containing 15 numbered tiles from 1 to 15 and one empty square.

The objective is to rearrange the tiles in ascending order by successively sliding an adjacent tile into the empty square (up, down, left, or right).

Why are some 4x4 puzzles unsolvable?

A 4Ă—4 sliding puzzle (even-width grid) is solvable if and only if the following condition is met: $ I + r $ is odd, where $ I $ is the total number of inversions (pairs of tiles $ (i, j) $ such that $ i > j $ with $ i $ appearing before $ j $ in the grid read row by row), and $ r $ is the position of the empty square counting rows from the bottom (1 for the last row, 2 for the second-to-last, etc.).

For the state [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14, 0], there is only one inversion $ (15,14) $, so $ I = 1 $, and the empty square is on the first row from the bottom, so $ r = 1 $. Since $ I + r = 2 $ is even, this configuration is unsolvable.

Are there any variations of the 4x4 sliding puzzle?

Yes, several variations exist:

— NĂ—N puzzle: larger grids (for example, 5Ă—5 or 6Ă—6), whose complexity grows exponentially with $ N $.

— Puzzle with constraints: some squares are blocked, or some tiles can only move according to specific rules.

— Toroidal (wrap-around) puzzle: the edges are connected, which profoundly alters the structure of the state graph.

— 3D puzzle: a cube-based extension, like the Rubik's Slide here (affiliate link) where moves occur in three dimensions.

How many configurations are there for the 4x4 puzzle?

The theoretical space of configurations is $ 16! $, but only $ \frac{16!}{2} = 10461394944000 \approx 10^{13} $ configurations are attainable in practice because of a parity constraint.

What is the maximum number of moves required to solve 15 puzzle?

The maximum number of optimal moves required to solve any solvable position is 80. This bound was established by computer-assisted exhaustive analysis.

There are 17 initial positions requiring 80 moves.

What algorithms should be used to solve a 4x4 sliding puzzle?

Several algorithms are suitable, with trade-offs between optimality, computation time, and memory usage:

— A*: an optimal and complete heuristic search algorithm if the heuristic is admissible and consistent. It uses $ f(n) = g(n) + h(n) $, where $ g(n) $ is the path cost from the initial state and $ h(n) $ is an estimate of the remaining cost (for example, the Manhattan distance enhanced by Linear Conflict, which remains admissible when correctly calculated).

— IDA*: a variant of A* that performs depth-first searches with an increasing cost threshold; it explores fewer nodes in memory at the cost of re-explorations.

— BFS (Breadth-First Search): theoretically optimal and complete, but impractical for 4x4 due to the combinatorial explosion of the state space.

— Metaheuristic methods: genetic or simulated annealing algorithms that allow for faster approximation of solutions, without guaranteeing optimality.

dCode uses IDA with a weighting system to find a solution quickly, even if it is not optimal.

Source code

dCode retains ownership of the "15-Puzzle Solver" source code. Any algorithm for the "15-Puzzle Solver" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "15-Puzzle Solver" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "15-Puzzle Solver" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.

Cite dCode

The content of the page "15-Puzzle Solver" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).

Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).

To cite dCode.fr on another website, use the link: https://www.dcode.fr/15-puzzle-solver

In a scientific article or book, the recommended bibliographic citation is: 15-Puzzle Solver on dCode.fr [online website], retrieved on 2026-02-06, https://www.dcode.fr/15-puzzle-solver

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best '15-Puzzle Solver' tool for free! Thank you!


https://www.dcode.fr/15-puzzle-solver
© 2026 dCode — The ultimate collection of tools for games, math, and puzzles.
â–˛  
Feedback