Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to develop a 8-square puzzle.
I need to know how i must arrange the 8 squares in order to solve the puzzle.

Any help/hint is appreciated.

Regards,
Posted
Comments
Sergey Alexandrovich Kryukov 5-Apr-14 2:02am    
And what is the problem? What have you tried so far?
—SA

1 solution

This should be enough to solve this problem:
http://msdn.microsoft.com/en-us/library/system.random%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/zd1bc8e5%28v=vs.110%29.aspx[^] (this is the only method you need, not counting the constructor).

Now, you should use some elementary logic and some rudimentary understanding of the probability theory to generate a random permutation: http://en.wikipedia.org/wiki/Permutation[^].

Basically, you should take into account the the generated random position of some square can be already busy by a previously generated position of another square. However, you don't have to invent the algorithm by yourself. Some of the algorithms are explained here:
http://en.wikipedia.org/wiki/Random_permutation[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900