I read through Magnus Hetland's book and noticed the Eight Queens problem, which I had solved some time ago using Visual Basic.
This time, I wanted to use a non-recursive solution. I randomly place each queen on board coordinates running from 0,0(top left hand corner of board) to 7,7(lower right hand corner of board)
Here's the interesting part: I can only get eight queens safely on the board perhaps every one in 20 runs. At least 12 or 13 of those times, I can place seven queens, while five or six times, I can only place six queens or even five!
Once a queen is safely placed, I establish her "territory". Once this is done, when I try to place a subsequent queen, I check for all placed queen's territories. Once I place six or seven queens, I have to give the program a lot more tries to try to find a safe square. And it can't always be done.
Does this sound right? Does trying to place each queen randomly cause this anomaly?
I can post my code(beginner code!) if anyone is interested in seeing it.
Best,
John
=================================
John Soares, Webmaster
Family Safe Surfinghttp://www.family-safe-surfing.net
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Tel: (810) 343-0571
Fa
x: (866) 895-3082
"Your best bet for online family-friendly resources"
=================================
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor