Search for a tool
8-Puzzle Solver

Tool/solver to solve a 3x3 puzzle in an instant: check the solvability of a configuration and get detailed solving steps.

Results

8-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 '8-Puzzle Solver' tool for free! Thank you!

8-Puzzle Solver

8-Puzzle Solver


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




See also: Magic Square

8-Puzzle Generator




Answers to Questions (FAQ)

What is a 8 puzzle? (Definition)

A 3x3 sliding puzzle, also called an 8-puzzle, is a game consisting of a grid of 9 squares (3 rows and 3 columns) containing 8 numbered tiles from 1 to 8 and one empty square.

The objective is to rearrange the tiles in ascending order (usually from 1 to 8, with the empty square in the last position) by successively sliding an adjacent tile towards the empty square, in any direction (up, down, left or right).

Why are some 3x3 puzzles unsolvable?

A 3x3 configuration is solvable if the total number of inversions in the sequence of tiles (ignoring the empty space) is even.

An inversion is a pair of tiles $ (i, j) $ such that $ i > j $ and $ i $ appears before $ j $ in a row-by-row reading (from left to right, then top to bottom), ignoring the empty tile.

If $ I $ is even, the configuration has a solution.

If $ I $ is odd, the configuration is unsolvable and has no solution.

Example: Configuration [1, 2, 3, 4, 5, 6, 8, 7, 0]: there is only one inversion $ (8, 7) $, so $ I = 1 $, and since $ I $ is odd, this configuration is unsolvable.

Are there any variations of the 3x3 sliding puzzle?

Several variations exist:

— N Ă— N sliding puzzle: larger grids (15-puzzle, 24-puzzle, etc.). The search complexity increases rapidly.

— Puzzle with constraints: some squares may be blocked or certain moves prohibited.

— Toroidal sliding puzzle: the left/right and top/bottom edges are connected.

— Higher-dimensional sliding puzzle: extensions into 3D where moves occur in a volumetric space.

Each variation modifies the combinatorial structure of the problem and its solvable properties.

How many configurations are there for the 3x3 puzzle?

The total theoretical space of arrangements of the 9 squares is $ 9! = 362880 $. However, only half of these configurations are attainable due to the parity constraint of the permutations. The exact number of solvable configurations is therefore: $ \frac{9!}{2} = 181440 $. This means that there are 181440 distinct starting positions.

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

For the 3x3 (8-puzzle), the maximum number of optimal moves required to solve a solvable position is 31. This bound was determined by computer-assisted exhaustive exploration.

Source code

dCode retains ownership of the "8-Puzzle Solver" source code. Any algorithm for the "8-Puzzle Solver" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "8-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 "8-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 "8-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/8-puzzle-solver

In a scientific article or book, the recommended bibliographic citation is: 8-Puzzle Solver on dCode.fr [online website], retrieved on 2026-02-22, https://www.dcode.fr/8-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 '8-Puzzle Solver' tool for free! Thank you!


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