← Back to 15 Puzzle

About 15 Puzzle

What Is It?

The 15 puzzle is the classic sliding puzzle from the 1870s.

Controls

Use the arrow keys (up, down, left, right) or click/tap on the tile you want to slide

Hitting 'u' is a shortcut for hitting the undo button. Exactly undoing your previous sequence of moves will actually count as an undo. Your move count will decrement.

Optimal Solution

To find the optimal solution (ie the solution that uses the least number of moves), I wrote a Rust program. It uses the A* search algorithm. The solution given is probably not unique; there are likely other solutions just as short, but there are none shorter.

Best Score

When you solve a puzzle, your score is the number of moves you took beyond the minimum. For example, if the puzzle can be solved in 50 moves and you took 60, your score is 10 over. Lower is better, and a score of 0 over means you solved it optimally. Your best score is shown above the board and is saved in your browser, so it sticks around between visits.

If you peek at the solution, that puzzle no longer counts toward your best score.

If you want a fresh start, the button below erases your saved best score. This can't be undone — your best score goes back to a blank slate, and the next puzzle you solve sets a new one.

Why?

One of my other hobbies is solving the Rubik's Cube. Like most cubers, I use the CFOP method, which is intuitive for humans, but far from optimal if considering only the number of moves. It has been proven that any Rubik's Cube can be solved in 20 moves or less, whereas the standard CFOP method solves a cube in about 55 moves.

Actually solving a cube optimally with the least number of moves is far outside current human capabilities. Whenever I watch a cube being solved optimally, it's as if by magic. At first, nothing seems to be happening, the cube is still fairly scrambled after many moves, and then all at once everything falls perfectly into place. The 15 Puzzle is much simpler than the Rubik's Cube, and I wanted to see how close I could get to solving one optimally. It turns out not close at all. When watching a perfect solve for a 15 Puzzle, it seems just as magical when all the tiles suddenly line up.

I've created 1000 boards with solutions.