Welcome, %1$s. Please login or register.

February 20, 2018, 07:00:39 AM
: 1
: 8 queens on a chessboard (Microsoft)!  ( 3786 )
« : May 16, 2007, 07:51:06 PM From Ria»

8 queens on a chessboard (Microsoft)!

Place 8 queens on a chess board in such a way that they cannot capture each other.

Liked It? Share it!


« #1 : May 25, 2007, 11:36:42 PM From spazinvader»

A very old problem.If you like to have,i can even give you a c program which generates the answers.There is not one unique solution for this.
« #2 : June 09, 2007, 10:48:20 PM From Prateek»

Hey Spazinvader, do send in the C code for this and post it in C section.
Thanks in advance.  :)
« #3 : June 16, 2007, 10:15:25 PM From spazinvader»

Could it be used as a puzzle?
If so then once again notify it here please.
I will make it in the C section.
Thanks for your notification
« #4 : January 22, 2008, 05:17:47 PM From thequark»

Actually it is a classical N queens problem often discussed when discussing constraint satisfaction problems (CSP) or backtracking algorithmic approach.

The most brute force approach would be to take a vector of 8 integers.
(0,0,0,0,0,0,0,0) where each element can vary from 0 to 8. ith number in the vector gives row number of queen in ith column. Now starting incrementing them to cover all the possible combinations (0,0,0,0,0,0,0,0) -> ... -> (7,7,7,7,7,7,7,7) which would be 8^8 and in general n^n. In each of the vector check whether a queen is capturing another one or not.

Now there can be various ways to enhance this algorithm e.g. assign row values from left to right and each time you try to assign a particular value check whether it conflicts with the existing values in left. The same value can't be present right as no two queens can be present at the same row and check for diagonal also.

There can be other strategies to solve the problem also

: 1
« previous next »


Best RatedList All>>


SMF 2.0.10 | SMF © 2015, Simple Machines | Contact Webmaster | OnlineFunDb.com © 2009/10 | Legal Disclaimer