Skip to content
UniKit

Number sliding puzzle

A playable number sliding puzzle (15-puzzle): click a tile next to the blank to slide it, or move the blank with the arrow keys / WASD. Boards are shuffled from a seed so they are always solvable, with live move count, Manhattan distance, inversion count and solved state — plus a real BFS shortest-solution hint for 3×3.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Number sliding puzzle board

Click a tile next to the blank to slide it, or press the arrow keys / WASD to move the blank.

Move 0 · Manhattan distance 20 · inversions 28 · New board ready
Moves
0
Manhattan distance
20
Inversions
28
Solvable
yes
Size
4×4

Arrow keys / WASD move the blank; you can also click a tile next to the blank.

Move log

0 moves this board

No moves recorded yet

What this tool does

  • Finish a 15-puzzle in the browser: click a tile next to the blank to slide it, put the blank back in the bottom-right corner to win, and undo whenever you like.
  • Reproduce a board someone shared: the same seed and size give the same board cell by cell, which is handy for checking answers or for teaching.
  • Check the classic solvability rule: the panel always shows the inversion count, the Manhattan distance and whether the board is solvable, updating after every move.
  • Stuck? Press Hint: for 3×3 a real BFS returns the shortest solution and the next move, while larger boards get a heuristic that shortens the Manhattan distance.

Example

Input

4×4 · shuffle seed 478837 · 24 shuffle steps

Output

4 × 4 number sliding puzzle (seed 478837, 24 shuffle steps)
 1  2  3  4
 5  . 10 15
13  9  6 11
14  8 12  7
Solvable: yes · inversions 28 · Manhattan distance 20 · 0 moves taken
Directions are up / down / left / right (u / d / l / r also work); the blank moves one cell that way.

The board comes from a real shuffle with seed 478837, and both the Manhattan distance (20) and the inversion count (28) are computed from it. Click the 11 in the bottom row or use the arrow keys to really slide the blank.

Frequently asked questions

How do I play?

Click a tile next to the blank and it slides in; or click the board once and use the arrow keys / W A S D (they move the blank in that direction). Put the tiles back in order 1…n²-1 with the blank in the bottom-right corner to win — the page then shows "Solved!".

Which piece do the arrow keys move?

The arrow keys and W/A/S/D move the blank: pressing left moves the blank one cell left, so the tile to its right slides into the old blank position. Clicking is the other way round — you click a tile and it slides into the blank. Both go through the same rule functions and count steps the same way.

Can the shuffle produce an unsolvable board?

No. The shuffle starts from the solved board and takes N random legal moves (size² × 1.5 by default, so 24 for 4×4) and every one of them is reversible, so the result is always solvable. The "Solvable" stat uses the inversion count plus the blank row: even inversions for odd sizes, plus the blank row counted from the bottom for even sizes.

How are the size, seed and shuffle steps chosen?

The size can be 3–6. Without an explicit seed it is derived as FNV-1a("puzzle|size") % 1000000 (478837 for 4×4, 35504 for 3×3). The same seed, size and shuffle count always give the same board, and "Restart this board" re-deals exactly that board.

Is the hint the optimal solution?

For 3×3, whose reachable space has only 181440 states, the hint is a real BFS shortest solution (labelled "BFS shortest solution for 3×3"). Above that the state space is far too large, so the hint is a heuristic that shortens the Manhattan distance: the direction is always legal, but not guaranteed to be shortest.

Is my board uploaded, and is anything stored?

Everything runs in your browser: no network requests and no localStorage writes, so a reload deals a fresh board. "Load a board from text" is parsed locally too — an invalid board reports an error instead of touching the current position.

Keywords:sliding puzzle

Related tools