Tiny Arcade five small games
  1. Tiny Arcade
  2. Fifteen

Fifteen

The 4×4 sliding puzzle. Fifteen numbered tiles, one gap, and a board that is guaranteed solvable every time.

Your browser does not support the canvas element. The game cannot run, but the rules are described below.
Moves 0 Best —

Arrow keys move the gap. Or click a tile beside it.Tap a tile beside the gap to slide it.

The rules

Fifteen uses a 4×4 grid holding tiles numbered 1 to 15 and one empty square. A tile adjacent to the empty square can slide into it. The goal is to arrange every tile in numerical order, reading left to right and top to bottom, ending with the gap in the bottom-right corner.

Controls

Arrow keys / WASDSlide the neighbouring tile into the gap
Click / tap a tileSlide that tile, if it is beside the gap
SpaceShuffle a new board

The solvability trap

Only half of the 16!/2 arrangements of this board can be reached from the solved position. A puzzle that randomises tile positions therefore has a coin-flip chance of being impossible — the player can shuffle a board and push tiles for an hour without ever knowing it cannot be finished.

This game avoids that entirely by starting from the solved board and applying a long series of random legal moves. Every reachable state is by definition solvable, so there is no need to compute the parity of the permutation at all.

How to solve it

Solve in layers, not in a rush. Place tiles 1 and 2 in the top row, then 3 and 4. Then do the same down the left column, and repeat for the second row and column. The last 2×2 block is solved by rotating: line up the three tiles in the wrong order relative to the corner and circle them through the gap.

The trick for a row's final pair is to place the second-to-last tile in the last column and the last tile just below it, then rotate both into position together. Trying to drop each tile straight into its home square usually ends with the two of them swapping endlessly.

Notes on the implementation

The board is a flat array of sixteen tile numbers, where 16 represents the gap. A move swaps one array entry with the gap index, so a move is a constant-time operation and the finish check only walks fifteen values. Tiles that are already in their correct place are tinted green, which makes the remaining work visible at a glance. The best score is the lowest move count, stored per browser.