Do a breadth-first search. From your starting position, find all of the 
positions you can reach in one move. From each of those, find all positions 
you can reach in one move. If you reach an already-reached position, just 
ignore that move; you either got to that position on an earlier move or via 
another path on this move. Continue this way until either you reach the 
solution state or you are not able to find any previously unreached 
positions. In the former case, you have determined the minimum number of 
moves to solve the puzzle. In the latter case, there is no solution.

Dave

On Sunday, September 28, 2014 10:07:56 AM UTC-5, Ravi Ranjan wrote:

> Yesterday I appeared for ACM USA Regionals, there I got the problem
>
> https://icpc-qual-14.kattis.com/problems/flipfive
>
> Can anyone help how to solve this kind of problem.
> Any links for similar problems ?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].

Reply via email to