Regarding the approach to solving the slide puzzle

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

+1
source share
1 answer

Yes, in fact, some puzzles are unsolvable. The way to find out is to try to solve two puzzles at a time: one of them is an original puzzle, and one of them is an original puzzle with two tiles. When you solve one riddle, you know that the other cannot be solved.

+3
source

All Articles