GenerateRandomSearch

Sliding Puzzle Generator

Exactly half of all arrangements of a sliding puzzle are impossible to solve, which is the famous trap: shuffling the tiles like cards gives you a coin-flip chance of an unsolvable board. This scrambles by sliding instead, so every puzzle it produces is genuinely solvable — and then confirms that independently using the parity rule, which decides solvability from the tile order and the position of the blank alone.

What this generator does

Scrambles from the solved board by repeatedly sliding a tile into the blank, which makes every position reachable by construction. It then confirms solvability a second way using the parity rule, and on the 3x3 board runs a breadth-first search over every reachable position to report the shortest possible solution.

How to use this tool

  1. Choose a board size and how many scrambling slides to apply.
  2. Solve it by sliding tiles back into order, blank in the bottom-right.
  3. On the 3x3 board, compare your solution length with the shortest one found by search.
  4. Increase the scramble count for a harder start — though the shortest solution grows more slowly than you would expect.

Understanding the controls

Board size
3 gives the 8-puzzle, 4 the classic 15-puzzle, 5 a 24-puzzle. Only the 3x3 board is small enough to search for the shortest solution.
Scramble moves
How many slides to apply from solved, between 1 and 200. No slide puts back the tile the one before it moved, so up to about ten slides the shortest solution is nearly always as long as the scramble; on the 3x3 board it stops growing at around 22 moves, reached by about sixty slides.
Seed
Any word reproduces the same scramble for as long as the generator is unchanged, so the same puzzle can be set for several people.

Worked examples

A 3x3 scramble, solved by search
Seed round10, 15 slides: the board 1 3 6 / blank 2 8 / 7 5 4, whose shortest solution is 13 moves, found by searching every reachable position from it.

Common use cases

  • Generating solvable practice puzzles for a physical or printed board
  • Teaching the parity invariant that decides solvability
  • Benchmarking a sliding-puzzle solver against a known optimum
  • Showing why shuffling tiles at random is the wrong way to scramble
  • Setting the same scramble twice from a seed

How this generator works

Sliding is its own guarantee: every move is reversible, so a board reached by sliding can always be returned by reversing the moves. The parity check is genuinely independent — it counts pairs of tiles that are out of order and, on an even-width board, adds the blank's row counted from the bottom, the bottom row being one. On an odd board the count must be even; on an even board the total must be odd.

Randomness and fairness

The scramble is random; solvability is guaranteed by construction and then verified by the parity rule. A seed reproduces the scramble exactly and is therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator is used.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • The shortest solution is only computed on the 3x3 board; a 4x4 has around ten trillion positions, which needs a proper solver rather than a breadth-first search.
  • Board sizes from 3x3 to 5x5.
  • The puzzle is displayed rather than played — there is no interactive sliding here.
  • On the 3x3 board a scramble past about sixty slides is no harder: the shortest solution settles around 22 moves, and no position needs more than 31. The larger boards go on getting harder for longer; how much longer is not measured here.
  • A scramble is gone on reload — note the seed to set the same one again.

Privacy and your data

The scramble and any search run in your browser alone. Nothing about the board or your seed leaves the device.