[Tutor] Re: Interesting anomaly with the Eight Queens problem

jsoares at Safe-mail.net jsoares at Safe-mail.net
Wed Apr 13 18:15:32 CEST 2005



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
jsoares at family-safe-surfing.net
jsoares at safe-mail.net

Tel: (810) 343-0571
Fax: (866) 895-3082

"Your best bet for online family-friendly resources"
=================================



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050413/b90ea036/attachment.html


More information about the Tutor mailing list