I started reading "Think Like A Programmer" by V Anton Spraul. That is the question.
The train technique mentioned in the book is great for the example seen in it. I tried to write a train approach method to solve the problem of sliding tiles.
Assuming that I am working on a subset of the complete problem, for the set of tiles below (as shown in the example in the book), the above approach works fine.
6 8 . 5 4 7
We move counterclockwise until we get 4,5,6 in order in the top row, and then move 8 in empty space so that everything is in order.
But for below I did not find a suitable method
. 8 6 7 4 5
Is it possible that there may be permutations where the puzzle is unsolvable?
Thanks,
/ Ms
source share