15 Puzzle

JavaScript

1
2
3
4

5
6
7
8

9
10
11
12

13
14
15
16

Objective: Create a game in the form of the classic 15 puzzle, which shipped on the first Mac.

Problem: Is there an easy way to determine which moves are possible at any point in the game?

Solution: Make a table of adjacent cells for each cell in the game. The permissible moves are the cells which are adjacent to the empty cell. No other moves are possible.