The N-Queens Problem


The N-Queens Problem

The N-Queen problem is simple to describe:

Given:

An N by N chess board.

Task:

Place N queens on the board so that they do not attack each other.

The following is a solution to an 8-Queens problem:

            Q         
                  Q   
Q                     
         Q            
   Q                  
                     Q
               Q      
      Q               

And here is a solution to a 16-queens problem (be patient, a large table is being loaded .... it may take a while, hopefully less than a minute, but it will be worth waiting for !!!! )

123456 7890123456
1    Q                                          
2          Q                                    
3                Q                              
4                      Q                        
5                            Q                  
6                                  Q            
7                                        Q      
8                                              Q
9 Q                                             
0       Q                                       
1             Q                                 
2                   Q                           
3                         Q                     
4                               Q               
5                                     Q         
6                                           Q   

With regard to the solution displayed above, you'll have to trust us here, or else check yourself that this is indeed a feasible solution.

In any case, this puzzle is an interesting combinatorial problem, which with a bit of imagination can be regarded as a typical OR problem. More details on this problem can be found in Kenneth Evans'article on this problem (ORN, January 1977 Issue, p. 13-14)

A JavaScript implementation