Here is a simple rule for telling if an 8 puzzle is solvable. Recall that our goal state is 1 2 3 4 5 6 7 8 0 where the 0 represents the blank. Now, consider the following arrangement of tiles 1 2 3 4 5 7 6 8 0 The first line is in the correct order. The second line is correct except that counter 7 comes before counter 6. We can call this violation of the order an "inversion". If the number of inversions is even then the puzzle is solvable. If the number of inversions is odd then the puzzle is unsolvable. Consider the puzzle 2 4 3 1 0 6 7 5 8 We have the following inversions 2 comes before 1 4 comes before 3 and 1 3 comes before 1 6 comes before 5 7 comes before 5 for a total of 6 inversions. This puzzle is solvable. Note that we don't need to consider the blank (0). More examples: 1 5 8 0 2 3 4 6 7 5 comes before 2 3 4 8 comes before 2 3 4 6 7 For a total of 8 inversions. This puzzle is solvable. 5 1 8 0 2 3 4 6 7 5 comes before 1 2 3 4 8 comes before 2 3 4 6 7 for a total of 9 inversions. This puzzle is not solvable. 2 0 7 8 5 4 3 6 1 2 comes before 1 7 comes before 5 4 3 6 1 8 comes before 5 4 3 6 1 5 comes before 4 3 1 4 comes before 3 1 3 comes before 1 6 comes before 1 for a total of 18 inversions. This puzzle is solvable 8 7 6 5 4 3 2 1 0 8 comes before 7 6 5 4 3 2 1 7 comes before 6 5 4 3 2 1 6 comes before 5 4 3 2 1 5 comes before 4 3 2 1 4 comes before 3 2 1 3 comes before 2 1 2 comes before 1 for a total of 28 inversions. This puzzle is solvable (although you may run out of memory before finding a solution).