# eight queens puzzle

(redirected from N-queens)

## eight queens puzzle

(algorithm)
A puzzle in which one has to place eight queens on a chessboard such that no queen is attacking any other, i.e. no two queens occupy the same row, column or diagonal. One may have to produce all possible such configurations or just one.

It is a common students assignment to devise a program to solve the eight queens puzzle. The brute force algorithm tries all 64*63*62*61*60*59*58*57 = 178,462,987,637,760 possible layouts of eight pieces on a chessboard to see which ones meet the criterion. More intelligent algorithms use the fact that there are only ten positions for the first queen that are not reflections of each other, and that the first queen leaves at most 42 safe squares, giving only 10*42*41*40*39*38*37*36 = 1,359,707,731,200 layouts to try, and so on.

The puzzle may be varied with different number of pieces and different size boards.

References in periodicals archive ?
A number of techniques have been developed for solving N-queens chessboard problem.
Batouche, A Quantum-Inspired Differential Evolution Algorithm for Solving the N-Queens Problem" The International Arab Journal of Information Technology, 7(1): 21-28 (2010).
9] Durango Bill's The N-Queens Problem", http://www.
The team also applied their method to a classic benchmark constraint satisfaction problem, the n-queens problem (where the goal is to place n queens on an n x n chessboard so that none attack any other).
That system performed even better than the original GDS scheduler/constraint satisfaction system (on the n-queens problem where GDS was able to solve 1 thousand queens problems in 11 minutes, the new min-conflicts systems solved 1 million queens in less than 4 (using comparable computational resources).
Since the min-conflicts approach "blew away" prior techniques on the benchmark n-queens problem by an over four orders of magnitude performance improvement, it clearly indicated a new focus for the field.
Due space reasons we show only experimental results measured in number of backtracks but the conclusion is the same using other performance metrics (nodes visited, time): for each problem the dynamic approach gains very good position in the global ranking (it was the best for N-Queens n=8; the second for N-Queens n=16, N-Queens n=20 and Magic Square n=3; and rank fourth for Magic Square n=4).
Number of Backtracks solving N-Queens (NQ) and Magic Square (MS) with different strategies Strategy NQ n=8 NQ n=16 NQ n=20 MS n=3 MS n=4 F + ID 10 542 10026 0 12 F + IDM 11 542 10026 1 51 MRV + ID 10 3 11 0 3 MRV + IDM 10 3 11 1 97 AMRV + ID 11 517 2539 4 1191 AMRV + IDM 11 517 2539 0 42 O + ID 10 542 10026 0 10 O + IDM 10 542 10026 1 29 Dynamic 6 404 629 1 23
APPLICACION TO PARALLEL SOLUTION ON A HETEROGENEOUS MULTICLUSTER OF THE N-QUEENS PROBLEM
The N-queens problem consists in placing N queens on an NxN board in such a way that they do not attacks one another [5][7][12].
For example, there are several orders of magnitude between the first and first- fail pure strategies in the n-queens problem.
We tested our strategies on several instances of the n-queen problem and of Latin squares.

Site: Follow: Share:
Open / Close