8 queens

LiMuBai
07-28-2004, 10:49 AM
here's another riddle:
can you place eight pieces on an 8x8 board, in a way that there are no two pieces in the same column/row/diagonal?


an empty board:

drunknhik
07-28-2004, 11:02 AM
here's another riddle:
can you place eight pieces on an 8x8 board, in a way that there are no two pieces in the same column/row/diagonal?


an empty board:

I have a very simple C code that gets every solution...so why bother

blindwig
07-28-2004, 11:21 AM
Well since everybody seems to have given up, the answer is:
If the string contains a carriage return followed by a linefeed, the rtf will only have it as a linefeed.

Therefore the two strings are not equal...

Now...if anybody can tell me why this happens?
Well, if I were to guess...

having LF as an EOL marker was a unix standard long before IBM started using CRLF. So maybe to keep to a bigger standard, an RTF will internally keep only the LF, but when doing something in windows it will add the CR to be standard in that environment?

I've noticed that if I have a unix text file, and I open it in notepad (which I assume is based on a textbox) the EOLs are not intrepreted properly. But if I open that same file in WordPad (which I assume is based on a RichTextBox), it adapts the EOLs properly.

blindwig
07-28-2004, 11:23 AM
here's another riddle:
can you place eight pieces on an 8x8 board, in a way that there are no two pieces in the same column/row/diagonal?


an empty board:
yes, there are several possibilities. This is a old chess-training exercise: place 8 queens on the board in such a way that none of them are inline with each other. (in chess, Queens move by columns, rows, or diagonals)

Wamphyri
07-28-2004, 11:48 AM
I have a very simple C code that gets every solution
Good for you. Did you want a prize?

...so why bother
For the same reasons anyone bothered to answer your riddle, for a simple mental exercise (or a simple google search).

drunknhik
07-28-2004, 11:59 AM
Well actually, it wasn't really a riddle...I had a real problem, and solved half the problem. This was just my way of getting people to answer the problem.

I'm working with somebody else's code. They used a bunch of rtb's, which could have easily been multiline textboxes.

When I changed them all to textboxes, there were no longer any problems.

Wamphyri
07-28-2004, 12:09 PM
When posting in the RT forum under the title of riddle, you've got to expect others to provide their own riddles (in fact if you do a search I believe there is a thread filled with riddles). If you had asked the question under tech discussions you'd have gotten probably as many responses and likely more specific to your problem. So is the problem fully solved or still half solved?

drunknhik
07-28-2004, 01:58 PM
When posting in the RT forum under the title of riddle, you've got to expect others to provide their own riddles (in fact if you do a search I believe there is a thread filled with riddles). If you had asked the question under tech discussions you'd have gotten probably as many responses and likely more specific to your problem. So is the problem fully solved or still half solved?

Well, I guess in once respect it is solved, in that multiline textboxes were a more normal choice than rtb's anyway...
And believe it or not, I derived that solution from this silly thread.
One of the earlier posts mentioned "RTF format" and, while "RFT format" doesn't really exist, I had the brainstorm that maybe it was a problem with RTF boxes...

Iceplug
07-28-2004, 04:03 PM
here's another riddle:
can you place eight pieces on an 8x8 board, in a way that there are no two pieces in the same column/row/diagonal?


an empty board:
Last I heard, that puzzle was impossible but some of its smaller counterparts were solvable. (The 4x4 board for instance)

LiMuBai
07-29-2004, 03:51 AM
it's possible...

blindwig
07-29-2004, 11:41 AM
the 8x8 queens problem is solvable - do a search for "eight chess queens" on goole and you'll get plenty of algorithms and answers.

ElderKnight
07-29-2004, 11:59 AM
the 8x8 queens problem is solvable - do a search for "eight chess queens" on goole and you'll get plenty of algorithms and answers.
You realize before very long that said queens have to be separated by knights' moves.

blindwig
07-29-2004, 02:33 PM
You realize before very long that said queens have to be separated by knights' moves.
you realize that a queen cannot perform a knight's move, so that wouldn't change the fact that you can have 8 queens that are not within each other's attack range ;)

blindwig
07-29-2004, 05:27 PM
you realize that a queen cannot perform a knight's move, so that wouldn't change the fact that you can have 8 queens that are not within each other's attack range ;)
OK, just beacuse I just had to know (and needed a good refreshing exercise (been putting in a lot of over time the past few weeks)) I wrote an semi-brute force (meaning semi-intelligent, doesn't try impossible combinations) to give me a list of ways to do this. I haven't manually verified each and every one, but doing a spot-check checks out.
for the 8 queens puzzle, I found 92 solutions: (put in code brackets to get scroll bars, I hate posts that go to long)

[0, 4, 7, 5, 2, 6, 1, 3]
[0, 5, 7, 2, 6, 3, 1, 4]
[0, 6, 3, 5, 7, 1, 4, 2]
[0, 6, 4, 7, 1, 3, 5, 2]
[1, 3, 5, 7, 2, 0, 6, 4]
[1, 4, 6, 0, 2, 7, 5, 3]
[1, 4, 6, 3, 0, 7, 5, 2]
[1, 5, 0, 6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 2, 0, 6, 3, 5]
[7, 2, 0, 5, 1, 4, 6, 3]
[7, 3, 0, 2, 5, 1, 6, 4]

using a "super-queen", that is, a queen that can perform a knight's move, there are zero possible solutions.

Iceplug
07-29-2004, 05:39 PM
After I wasted my time making an interactive program finally figuring it out.

Super-queen, huh?

blindwig
07-29-2004, 05:56 PM
Wow, this little puzzle has got me thinking. Ways to make a brute-force method more intelligent.
Using the 8 Queens puzzle:
there are a grand total of 178,462,987,637,760 (that's 64*63*62*61*60*59*58*57) ways to place 8 pieces on an 8x8 chess board.
but since there are 8 queens to place, and none can occupy the same row, then each must be in it's own row, so you dont have 64 possible positions for each queens, you have 8. So now you have 16,777,216 (8*8*8*8*8*8*8*8) possible configurations. But since you also can't have 2 queens on the same column, you only need to consider 40320 (8*7*6*5*4*3*2=8!) solutions.
Using a branching stategy to account for diagonals, I eventually got to the point where I only needed to consider 1965 positions, and discovered 92 correct solutions of those. Obviously it was much better to brute-force nearly two thousand solutions, versus nearly two hundred trillion.
Has anyone else ever attempted this puzzle, found a better way to do this (fewer possibilities)? I'm going to google right now, I just wanted to give a good effort before I went searching for the answer...

blindwig
07-29-2004, 06:01 PM
After I wasted my time making an interactive program finally figuring it out.

Super-queen, huh?
I wanted to make a program that would let me put a queen down and it would automatically mark off the spaces that were no longer available. I was going to use an 8x8 array of check boxes (check where you want to put a queen, and it will automatically disable check boxes that are covered by other queens) but I'm at work, using VB.Net, and I just discovered that VB.Net doesn't have control arrays - ARGGGG!!! ***??? MS suddenly decided that we need to go back to dealing with each control individually? Phtttttpppp to that...
Anyway, so I wrote that above program in Python (I'm supposed to be boning up Python for work anyway, so it's excusable ;) kinda-sorta)

Iceplug
07-29-2004, 06:51 PM
I used a control array in my attachment there :chuckle:.

blindwig
07-29-2004, 07:04 PM
I used a control array in my attachment there :chuckle:.
Oh, cool... it didn't run the first time I tried for some reason. It's working now. That's a lot like what I was thinking of. Except on yours you cannot uncheck a box (well, you can, but it doesn't re-enable the squares that are no longer affected). I know what you're going to say - how do I figure out which squares I can turn back on? I thought of 2 ways:
record the positions of the queens placed so far. When a queen is removed, reset the whole board and then re-disable the boxes that are guarded by each queen. This is kinda sloppy, but it would work.
use the control .tag (or something) to record bits for each queen that guards that square. Queen #x has bit #x, so queen 0=1, Q2=2, q3=4, q4=8, etc. To undo a queen (when it is removed from the board) go through all .tags and AND NOT out the bit set by the now removed queen. If the result is zero (meaning no queen is currently guarding this square) then you can re-enable that square.

Iceplug
07-29-2004, 07:16 PM
Yes, I was originally going for the unchecking of the squares, but then I just decided to just make the thing reset when you click on the form (since this was going to be my personal app until I decided to post it).

I had an idea of how to turn on the squares, and oddly enough you mentioned them both :p.

ElderKnight
07-30-2004, 06:09 AM
you realize that a queen cannot perform a knight's move, ...
Of course. My point was that the opposite corner of a 3x2 rectangle is the nearest safe point for each additional queen.

ElderKnight
07-30-2004, 06:13 AM
... Super-queen, huh?

Actually, there's a fairly substantial literature on variant forms of chess, involving bishop+knight (usually "archbishop") and rook+knight ("chancellor") pieces and others. I think the queen+knight is the "empress" or the "amazon", and awfully difficult to defend against.

I suggested in an earlier discussion that while there were many excellent chess programs out there, I knew of none that would let one tailor the board configuration, pieces and rules.

ElderKnight
07-30-2004, 06:16 AM
... I'm going to google right now, I just wanted to give a good effort before I went searching for the answer...
I'm pretty sure that Martin Gardner discussed the problem in his *Scientific American* column sometime in the 1970s.

LiMuBai
07-30-2004, 09:03 AM
oohh, can I join? :)

attached my attempt at generating the solutions. I only got 2 solutions and I can't find the problem with the code...
anyone wants to take a look?

blindwig
07-30-2004, 01:14 PM
oohh, can I join? :)

attached my attempt at generating the solutions. I only got 2 solutions and I can't find the problem with the code...
anyone wants to take a look?
I can't run your code because I'm using VB.Net,... and why are you using gosub?
Anyway, I'm trying to read it, I'm not sure I exactly understand everything. And I'm not quite sure how your "resume" array is working...
Let me see if I can explain my logic, and you can compare that to yours:
I have an array of 0-63 for my board (let's call this "board")
I have an array of 0-7 for my queens, 1 for each row (let's call this "queens")
I set all my board to zero
Initally I set all my queens to zero, but this doesn't matter...
I put queen 0 at position 0, and put her bit (bit 0 = 1) on all squares she affects
I take my second queen and put her on position 0, but can't because that is guarded by queen 0. I put queen 1 on position 1, but that is also guarded by queen 0. So I put my queen 1 on position 2. Safe. Put her bit (bit 1 = 2) on all the squares she guards)
I put queen 2 on positoin 0, but it's guarded ... put her on position 4
I put queen 3 on position 1
I put queen 4 on position 3
No queen can be placed on row 5, so I go back to 4
remove queen 4 all of her bits (bit 4 = 16) from the board
I put queen 4 on position 7
Again I have nowhere to put queen 5, so I again go back to queen 4.
Queen 4 cannot be placed anywhere else, so I remove her form the board and go back to queen 3.

See how that works? It's a recursive function, and once you have recursed 8 levels deep (meaning you have placed all the queens) then you have found a valid solution. Using this method I only had to consider 1965 possibilities, and came up with 92 solutions. That's a 4.68% success - pretty good for brute force, I think.

So if you look at my list of solutions, look at the first one:
[0, 4, 7, 5, 2, 6, 1, 3]
that's queen 0 at position 0, queen 1 at position 4, queen 2 at position 5, etc...
Looks like this (with queens on the rows, row 0 at the top, position 0 at the left):
Xooooooo
ooooXooo
oooooooX
oooooXoo
ooXooooo
ooooooXo
oXoooooo
oooXoooo

LiMuBai
07-30-2004, 01:23 PM
that's about the same thing I did...
the first solution I get is [0,4,7,5,2,6,1,3] like you said.
the second is [3,5,7,2,0,6,4,1]
and then nothing, so it must be something in the resume var, but I just can't see it...

instead of variables I use the enabled state of checkboxes to determine if a position is valid.
when running through the possibilities of a level, I only transfer to the next if there are any possibilities in it (save a call)
and if there possibilities left for the next level when on level 7, I return the solution (no need to call level 8 since there's gonna be 1 possibility anyway).

LiMuBai
07-30-2004, 01:28 PM
the first level gets the array (0,1,2,3,4,5,6,7) from the click event

Dim LBResume%(1 To 7)

'scan for the next valid solution
Private Function Scan(ByRef oldPos() As Integer, ByVal Level As Integer) As Boolean

Dim newPos%(), i%, n%, c%

Scan = False

For i = LBResume(Level) To UBound(oldPos)

'when the checkbox is checked the invalid checkboxes are diabled
cbxBoard(oldPos(i)).Value = vbChecked

ReDim newPos(0 To 7): c = 0

'enumerate the valid positions in the next level
For n = Level * 8 To Level * 8 + 7
If cbxBoard(n).Enabled Then
newPos(c) = n
c = c + 1
End If
Next n

'if there are some
If c Then
'if this is the level before the last
If Level = 7 Then
'there can only be one possibility for the next one
cbxBoard(newPos(0)).Value = vbChecked
LBResume(7) = i + 1 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Scan = True
GoTo CleanUp
Else
ReDim Preserve newPos(c - 1)
'scan the next level
If Scan(newPos(), Level + 1) Then
LBResume(Level) = i
Scan = True
GoTo CleanUp
End If
End If
End If

'when the checkbox is unchecked the invalid checkboxes are enabled
cbxBoard(oldPos(i)).Value = vbUnchecked

Next i

CleanUp:

Erase newPos

End Function

oldPos holds the possibilities for the Level the function is currently on.
newPos holds the poses for the next level.

oh, the gosub... I like it. :D why not?

blindwig
07-30-2004, 01:43 PM
that's about the same thing I did...
the first solution I get is [0,4,7,5,2,6,1,3] like you said.
the second is [3,5,7,2,0,6,4,1]
and then nothing, so it must be something in the resume var, but I just can't see it...

instead of variables I use the enabled state of checkboxes to determine if a position is valid.
when running through the possibilities of a level, I only transfer to the next if there are any possibilities in it (save a call)
and if there possibilities left for the next level when on level 7, I return the solution (no need to call level 8 since there's gonna be 1 possibility anyway).
Hmm.. you're skipping out on solutions. There are actually 4 different solutions with queen 0 at position 0, 8 solutions with queen 0 at positon 1, etc..
your solutions #2 is actually my solution #38 (counting from 0; that's #39 to normal humans ;) )
I'll attach for you my list of possibilities. These are printed right before a queen is moved (meaning that a solution was not found on this branch) Get you program to print out it's possibilities as it goes, and check them against this list. If our logic is the same, then our possibilites should be the same also.

LiMuBai
07-30-2004, 01:56 PM
yup, it's working... 92 solutions.
it's something with the resume, but what????

OMG, I'm going crazy...

LiMuBai
07-30-2004, 02:00 PM
hey, I only needed to consider 1964...:p :D

LiMuBai
07-30-2004, 02:15 PM
see the line I marked with arrows? (post #34)
if I change it to
LBResume(7) = i ' + 1then it will repeat the same (first) solution all the time
but when it's
LBResume(7) = i + 1it's only getting the 2 solutions...

does that make sense????

LiMuBai
07-30-2004, 02:52 PM
oh why am I so stupid???
I didn't set the resume var for the current level to 0!

just add this little line after the Next i

LBResume(Level) = 0

so stupid.. *slapping myself*

blindwig
07-30-2004, 03:00 PM
OK, I'm starting to see what you're doing. You generate an array of possibillities for each row (you call them levels) before trying any of them. I just run though that loop and do my tries right in the loop, without bothering to record and then itterate the results. But now I understand what you're doing.
I'll show you my code, but I'm not sure what good it would do you since it's in Python, but maybe you can get the gyst of it:
def tryQueen(num):
global tries
global board
global queens
global solutions
if (num <= 7): #Make another try
tries+=1
#try the queen in all possible places
pos=0 #start with position zero
while (pos <= 7):
queens[num]=pos
if checkBoard(num,pos)==0: #the board is clear
setQueen(num,pos) #place the queen
tryQueen(num+1) #try the next queen
removeQueen(num) #remove the queen
pos+=1 #try the next position
else: #Recursed 8 levels - solution found!
solutions.append(queens[:])

blindwig
07-30-2004, 03:03 PM
hey, I only needed to consider 1964...:p :D
A good year, yes, but you're living in the PAST man, you need to get with the NOW

:p

blindwig
07-30-2004, 03:12 PM
Actually, there's a fairly substantial literature on variant forms of chess, involving bishop+knight (usually "archbishop") and rook+knight ("chancellor") pieces and others. I think the queen+knight is the "empress" or the "amazon", and awfully difficult to defend against.

I suggested in an earlier discussion that while there were many excellent chess programs out there, I knew of none that would let one tailor the board configuration, pieces and rules.
there is also a version of Chess I've seen where you put the pieces on the corners instead of the squares, so you effectively have a 9x9 board. It's layout is much like a normal chess board, except you have a queen on either side of the king, and one (or was it both) of them is your empress or amazon or whatever.

LiMuBai
07-30-2004, 03:12 PM
:chuckle:

here's the finished project:

blindwig
07-30-2004, 05:42 PM
OK, Next riddle: How many Unique solutions?
Take a solution on the list. Go through the list and find a mirror and an inverse of this solution (it's inverted mirror will be it's 180 degree rotation). Now find the 90 degree rotation, 180 degree rotation, and 270 degree rotation, of the original and the variants, and remove them all from the list.
Do this for each solution.
For example, the first solution:
[0, 4, 7, 5, 2, 6, 1, 3]
It's mirror is #31:
[3, 1, 6, 2, 5, 7, 0, 4]
It's inverse is #91:
[7, 3, 0, 2, 5, 1, 6, 4]
it's 90 degree rotation is #21
[2, 5, 3, 1, 7, 4, 6, 0]
it's 180 degreee rotation is #59:
[4, 6, 1, 5, 2, 0, 3, 7]
it's 270 degree rotation is #88:
[7, 1, 3, 0, 6, 4, 2, 5]
etc

So how many unique solutions that are not variants of each other (rotated inverted mirros, etc)

Mike Rosenblum
07-30-2004, 07:08 PM
Don't have to be separated by Knights, moves, but yes if solving by hand, this is a good general rule of thumb to start with. Solving for all solutions esp. considering reflections and rotations (if one only wants truly unique solutions) would require a computer of course, but you can find some by hand with out too much trouble.

[Edit: LOL, I was replying to the end of the 1st page without realizing that there were two more pages... Doh! :whoops: Don't worry, I'll catch up...]

LiMuBai
07-31-2004, 01:59 AM
the first thing that comes to mind is scanning only half of the first level (row)...
cutting down the results by half. (and the number possibilities you have to scan)

KermitDFrog
07-31-2004, 07:19 AM
it is possible to solve any type of this problem with any size board as long as the number of queens you are using is not > the lesser of number of rows/columns, so, theoreticly, you could have a 100000x100 board, and only fit 100 not interfering queens, further more, on a infinite by 8 board, you could (easily) fit 8 queens.
I actually have a nice peice of C code I've been running for about a year, its gotten out to a 10284x10284 board, every one to that point has been solvable.
the real question occurs, if you had 8 super queens, being those that can perform knight moves, how big would the board have to be to fit all of them?

find the smallest board.

Iceplug
07-31-2004, 07:32 AM
With any board with dimensions R by 2R - 1, you can just fit the queens on a diagonal.
For instance an 8 x 15 board will let you put a queen on each column, as long as the next queen is two rows down from the previous.
The same applies to 2R - 1 by R boards.

Other solutions to the board will also consist of the solutions to the R by R board and its shifted versions as well (they're also solutions to rectangular boards).

Boards that are smaller than R by 2R - 1 are the more interesting ones. :)

LiMuBai
07-31-2004, 10:11 AM
found 8 super queens on a 9x9, 10 on a 10x10

charlie
07-31-2004, 10:23 AM
This problem was a question of one of my tests in college... :mad:

blindwig
08-03-2004, 02:58 PM
I did some searching on the internet, and it seems that there are indeed 92 possible solutions (using 8 queens on an 8x8 board) so at least I know my solution was right.

So then I wrote a routine that eliminates duplicates - mirrors, inveres, mirrored inverses, rotated, mirrored rotated, inverted rotated, and mirrored inverted rotated. According to the info I found, there are only 12 unique solutions, but I only found 11 (I don't know where this odd number comes from) And another site that said that there is only actually 6 solutions (of the 12, half are reflections, or something??? I didn't understand what they ment)

Here's my final results (the 11):

[0, 4, 7, 5, 2, 6, 1, 3]
Xooooooo
ooooXooo
oooooooX
oooooXoo
ooXooooo
ooooooXo
oXoooooo
oooXoooo
[0, 5, 7, 2, 6, 3, 1, 4]
Xooooooo
oooooXoo
oooooooX
ooXooooo
ooooooXo
oooXoooo
oXoooooo
ooooXooo
[1, 3, 5, 7, 2, 0, 6, 4]
oXoooooo
oooXoooo
oooooXoo
oooooooX
ooXooooo
Xooooooo
ooooooXo
ooooXooo
[1, 4, 6, 0, 2, 7, 5, 3]
oXoooooo
ooooXooo
ooooooXo
Xooooooo
ooXooooo
oooooooX
oooooXoo
oooXoooo
[1, 4, 6, 3, 0, 7, 5, 2]
oXoooooo
ooooXooo
ooooooXo
oooXoooo
Xooooooo
oooooooX
oooooXoo
ooXooooo
[1, 5, 0, 6, 3, 7, 2, 4]
oXoooooo
oooooXoo
Xooooooo
ooooooXo
oooXoooo
oooooooX
ooXooooo
ooooXooo
[1, 5, 7, 2, 0, 3, 6, 4]
oXoooooo
oooooXoo
oooooooX
ooXooooo
Xooooooo
oooXoooo
ooooooXo
ooooXooo
[1, 6, 2, 5, 7, 4, 0, 3]
oXoooooo
ooooooXo
ooXooooo
oooooXoo
oooooooX
ooooXooo
Xooooooo
oooXoooo
[1, 6, 4, 7, 0, 3, 5, 2]
oXoooooo
ooooooXo
ooooXooo
oooooooX
Xooooooo
oooXoooo
oooooXoo
ooXooooo
[2, 5, 1, 4, 7, 0, 6, 3]
ooXooooo
oooooXoo
oXoooooo
ooooXooo
oooooooX
Xooooooo
ooooooXo
oooXoooo
[2, 5, 7, 1, 3, 0, 6, 4]
ooXooooo
oooooXoo
oooooooX
oXoooooo
oooXoooo
Xooooooo
ooooooXo
ooooXooo

blindwig
08-03-2004, 03:13 PM
OK, I found the problem. Look at this solution:

[2, 4, 1, 7, 0, 6, 3, 5]
ooXooooo
ooooXooo
oXoooooo
oooooooX
Xooooooo
ooooooXo
oooXoooo
oooooXoo

It's inverse is the same thing as it's mirror (weird, eh?) So it's inverted mirror (or it's mirroed invert) is equal to itself, so when it remove it's mirrored invert from the solution list, it was removing itself. That's why I only got 11 solutions.

OK, I just fixed my routine so it only removes a variant solution if that solution is not the same as the original solution. Now I get all 12 solution roots.

LiMuBai
08-03-2004, 06:11 PM
hey blingwig, could you post a link to the site where they said there's only 6 solutions?

and are these the solutions you get:
0,4,7,5,2,6,1,3
0,5,7,2,6,3,1,4
1,3,5,7,2,0,6,4
1,4,6,0,2,7,5,3
1,4,6,3,0,7,5,2
1,5,0,6,3,7,2,4
1,5,7,2,0,3,6,4
1,6,2,5,7,4,0,3
1,6,4,7,0,3,5,2
2,4,1,7,0,6,3,5
2,4,7,3,0,6,1,5
2,5,1,4,7,0,6,3

here's my code:

LiMuBai
08-04-2004, 04:19 AM
i think I figured out how there's 6... shifted variations.
take a look at the first two solutions in my list:
draw the 2nd one and rotate it 180. now shift all the queens 1 pos to the right and 1 pos downwards.
now it should fit perfectly on top of the first solution....

more:
take the fourth solution, mirror it (top<->bottom) and shift it one pos down
now it fits on the third...

blindwig
08-04-2004, 11:13 AM
Don't have to be separated by Knights, moves, but yes if solving by hand, this is a good general rule of thumb to start with. Solving for all solutions esp. considering reflections and rotations (if one only wants truly unique solutions) would require a computer of course, but you can find some by hand with out too much trouble.

Hey Mike, was that attached thumbnail your first solution? Do you realize you have 2 different rows that each have 2 queens on them? :p

blindwig
08-04-2004, 11:16 AM
hey blingwig, could you post a link to the site where they said there's only 6 solutions?
Hmm I can't seem to find it again. Before I was googling for "Eight Queens Puzzle" or something to that effect when I found it the first time.
and are these the solutions you get:
Yes, those are the same solutions that I got - see the 2 posts right before your post: ;)
http://visualbasicforum.com/showpost.php?p=813713&postcount=44
http://visualbasicforum.com/showpost.php?p=813731&postcount=45

blindwig
08-04-2004, 11:19 AM
This problem was a question of one of my tests in college... :mad:
so... was it one of the tests you passed? ;)

charlie
08-04-2004, 11:27 AM
YES! But it did take me a lot of time! I think I made a non-good solution for the problem, but I passed and I'm happy... :p

LiMuBai
08-05-2004, 02:00 AM
Yes, those are the same solutions that I got - see the 2 posts right before your post: ;)
:whoops:

Hmm I can't seem to find it again. Before I was googling for "Eight Queens Puzzle" or something to that effect when I found it the first time.
what about the shifted variations I suggested?
does that come close to what they said? and what do you think?
unfortunately, I can't find any other pairs....

Iceplug
08-05-2004, 05:12 AM
Hey Mike, was that attached thumbnail your first solution? Do you realize you have 2 different rows that each have 2 queens on them? :p
Looks the first three rows were all shifted down accidentally somehow. :D Cheater!

Mike Rosenblum
08-05-2004, 10:11 AM
Looks the first three rows were all shifted down accidentally somehow. :D Cheater! Ahahaha... Sorry guys! :p

I was so tired that night, replying to Post #3 then you guys were already on, like #22 at that point... I was doing it by hand and I really thought that it was legit! LOL...

Ok, here's another one, done by hand. Even sticking to the "knights move" adage, it's not that easy! But I finally hit on this:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum