Department of Mathematics, Statistics
and Computer Science
Wim Ruitenburg's Fall 2007 MATH025.1001
Eight Queens
A chess board has 8 by 8 equals 64 fields.
The classical game of chess is not what we will discuss.
Instead, we focus on a few kinds of pieces used in the game.
A piece like a rook or a queen occupies one field on the board, from where it
can `strike' other pieces following certain rules.
For example, a rook can strike each piece with which it shares a row or a
column.
A queen can strike each piece with which it shares a row, a column, or
one of the diagonals on which it stands.
In the example below, imagine a queen on the red field on row 6, column 3.
Then this queen can strike all pieces on the yellow fields.
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
Problem: How many queens can we fit on different fields on the board, such that
no queen can strike another?
Below we solve the problem through several steps.
A little trial and error shows that we can put 7 queens on different
field on the chessboard with no-one able to strike another.
So the question quickly reduces to find whether we can put 8 queens on the
board.
In theory we can find all solutions with 8 queens on the chessboard.
Simply try all possible positions:
For the first queen we have 64 choices.
For the second queen we have 63 choices.
For the third queen we have 62 choices.
For the 4th queen we have 61 choices.
For the 5th queen we have 60 choices.
For the 6th queen we have 59 choices.
For the 7th queen we have 58 choices.
For the 8th queen we have 57 choices.
The total number of choices is 64 * 63 * 62 * 61 * 60 * 59 * 58 * 57, which
equals 178462987637760.
In practice, this is way too much.
We quickly observe that 8 queens, if at all possible, must be in 8
different columns.
So for the first queen we have 8 choices in the first column.
For the second queen we have 8 choices in the second column.
For the 3rd queen we have 8 choices in the 3rd column.
And so on.
The total number of choices is 8 * 8 * 8 * 8 * 8 * 8 * 8 * 8, which equals
16777216.
This is still a big number, but we can find all ways to put 8 queens on the
chessboard, if it were really important to us.
Next we observe that the queens must also be in different rows.
We add that further restriction to the result above.
For the first queen we have 8 choices in the first column.
For the second queen we have 7 choices in the second column.
For the 3rd queen we have 6 choices in the 3rd column.
For the 4th queen we have 5 choices in the 4th column.
For the 5th queen we have 4 choices in the 5th column.
For the 6th queen we have 3 choices in the 6th column.
For the 7th queen we have 2 choices in the 7th column.
For the 8th queen we have 1 choice in the 8th column.
The total number of choices is 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1, which equals
40320.
Note that this is exactly the number of ways that we can put 8 rooks on
a chessboard.
At about this stage, mathematics mostly fails us.
What is left is a down-to-earth search.
Start putting queens on the chessboard, beginning with the left column, and
first at the bottom left.
Each time some columns have been filled with queens that cannot strike one
another, go to the next column to the right and try to put a queen in the first
possible field where she can not be struck by earlier queens.
This leads to a partial setup as follows:
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
Now all fields of the 6th column are under attack.
So this partial configuration can not be extended to a successful one.
At this stage we backtrack my moving the most recently placed queen to
the next available field:
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
and try again to put a 6th queen in the 6th column, and so on.
Once all possibilities are exhausted, it may be necessary to backtrack by more
than one column.
When we keep this search up, our first solution will be
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
We made an informal distinction between the mathematical part of the
problem, and the non-mathematical part.
This distinction can not be made precise.
Nonetheless, it illustrates how mathematics tends to function in common
problems.
A next step is to look for solutions that are in some ways nicer.
For example, the following is a `nice' solution (why?):
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
In class we also constructed solutions on a 1 by 1 board, on a 4 by 4 board, on
a 5 by 5 board, 6 by 6, 7 by 7, 9 by 9, and 10 by 10.
For the larger board solutions, we may use a smaller board solution with an
empty diagonal, then add a row and column with a new queen in the new corner
that strikes this empty diagonal and so misses all the existing queens.
More Queen Problems
Once a specific problem has been solved, mathematicians tend to discover
new circumstances where their methods can be applied again, sometimes with
stronger effect.
In this case, try to solve the queens problem on square boards of different
sizes.
Consider the following solutions, one on a 5 by 5 board, the other on a 7 by 7
board:
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
6
7
1
2
3
4
5
6
7
These solutions have a pattern.
Using mathematics, we can extend this pattern to solutions on infinitely many
larger boards.
Note that 5 and 7 are prime numbers.
Just to show that there is more mathematics behind the problem, here is
a beautiful solution to the 17 queens problem on a 17 by 17 board (note that 17
is prime):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Based on the previous examples, it is tempting to make a conjecture on
prime numbers versus `nice' solutions.
By now you should know to be cautious in my class.
Maybe first try to find a `nice' solution on a 25 by 25 board (note that 25 is
not prime).
Last updated: November 2007
Comments & suggestions:
wimr@mscs.mu.edu