Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find 12 unique solutions of 8 queens problem?

Status
Not open for further replies.

Antzelinaki

Programmer
Jun 16, 2012
14
0
0
I have writen a program that finds 92 solutions of 8 queens placed on a chessboard without attack each other.
I have found through a google search that 12 of these are unique from symmetry. So...
I thought to take totally 368 solutions of 92 x 4 because, if we turn the chessbord which is a rectange shape from all the sides, each Solution has 3 in addition solutions too by the rest of sides of the rectangle. I wrote a piece of code to compare each one of the 368 solutions. But 368 are unique too!!! And I am confused. Here is the little piece of code. I don't know if there is another way of that I refered to find the 12 unique solutions. It seems that that I fall behind to find that logic. If anyone can help me about logic or whatever useful I would appreciated it so much.
Thank you in advanced.

[sub]For k = 0 To AllSols.Length - 2
For i = 0 To 7
If k < AllSols.Length - 2 Then
If AllSols(k).Item(i).Column = AllSols(k + 1).Item(i).Column Then
Same = Same + 1
End If
End If

Next
If Same < 7 Then
Distinct = Distinct + 1
End If
Same = 0
Next
MsgBox(Distinct)
[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top