15 Puzzle Solver

Homepage

Literate programming

The 15 puzzle is a game where 15 numbered square tiles are arranged on a 4 x 4 grid. They can be moved to fill the empty square. The objective of the game is to arrange the tiles so that they are in order:

+----+----+----+----+
|  1 |  2 |  3 |  4 |
+----+----+----+----+
|  5 |  6 |  7 |  8 |
+----+----+----+----+
|  9 | 10 | 11 | 12 |
+----+----+----+----+
| 13 | 14 | 15 |    |
+----+----+----+----+

This program takes a given board constellation as its input and returns the moves required to solve it in the least number of moves. It is written using noweb.

15_puzzle_solver.pdf

15_puzzle_solver.nw

15puzzle_solver.c