The classic sliding puzzle game. Arrange numbers in order by sliding tiles into the empty space. Test your logic and strategy skills!
How to Play: Click on any tile adjacent to the empty space to move it. The goal is to arrange all numbers in order from 1 to N (where N is the total number of tiles). The empty space should be at the bottom-right corner when solved.
The Number Grid Puzzle, also known as the 15-puzzle, sliding puzzle, or Gem Puzzle, is a classic puzzle invented by Noyes Palmer Chapman in the 1870s. It became a worldwide craze in the 1880s. The puzzle consists of a grid of numbered squares with one square missing, allowing adjacent tiles to slide into the empty space.
Mathematical Significance: The 15-puzzle is often used in computer science to study state space search algorithms. It's a classic example of a problem that can be represented as a graph, where each configuration of the puzzle is a vertex, and moves between configurations are edges.
A configuration of the 15-puzzle is solvable if and only if:
1. For a grid with even width (like 4x4):
(number of inversions + row number of empty space) is even
2. For a grid with odd width (like 3x3):
number of inversions is even
Where an inversion is a pair of tiles (a,b) such that a appears before b but a > b.
This solvability condition helps determine if a randomly shuffled puzzle can be solved. About half of all possible configurations are unsolvable.
| Grid Size | Number of Tiles | Possible Configurations | Solvable Configurations | Maximum Moves (God's Number) | Difficulty Level |
|---|---|---|---|---|---|
| 3×3 | 8 | 181,440 | 90,720 | 31 | Easy |
| 4×4 | 15 | ≈1.3×1013 | ≈6.5×1012 | 80 | Medium |
| 5×5 | 24 | ≈7.8×1024 | ≈3.9×1024 | Unknown | Hard |
| 6×6 | 35 | ≈1.6×1041 | ≈8.0×1040 | Unknown | Expert |
Layer-by-Layer Method: Solve the puzzle one row at a time, starting from the top. First solve the first row (except the last two tiles), then the second row, and so on. This method is systematic but not always optimal.
Corner-First Method: Start by solving the corners, then the edges, and finally the interior tiles. This approach often leads to more efficient solutions than the layer-by-layer method.
Thistlethwaite's Algorithm: A computer algorithm that reduces the puzzle to a simpler form in stages. It's guaranteed to find a solution but not necessarily the shortest one.
IDA* Search Algorithm: Iterative Deepening A* is often used to find optimal solutions to the 15-puzzle. It uses a heuristic (like Manhattan distance) to guide the search for the shortest solution.
| Grid Size | Moves | Time |
|---|---|---|
| 3×3 | - | - |
| 4×4 | 16 | 00:01 |
| 5×5 | - | - |
| 6×6 | - | - |