A program to solve slider puzzles. Written in C. It should take a few seconds at most to run.
Open this link in another tab and then run make
.
Run the program like ./slidersolver 185423706 123456780
to solve a 3x3 puzzle, and then print out a trace of the solution. (0 is the free space.)
This is made for 8-puzzles, but for larger slider puzzles like the common 15-puzzle you'd have to modify several parts of the program, both constants and logic.
This code basically just bruteforces a solution, by exploring and caching the possibility state. There are some optimizations, but only in the form of data structures, not mathematical insights. (Some of the code runs mathematical checks to try to ensure the puzzle is valid, but this does not actually help solve the puzzle.)
- Make (optional)
- GCC, or another c compiler (for Make, the other c compiler must be aliased to gcc) (mandatory)