5 queens

John Machin sjmachin at lexicon.net
Sat Dec 22 18:49:58 EST 2007


On Dec 23, 10:18 am, cf29 <fcharlypil... at gmail.com> wrote:
> On Dec 23, 12:39 am, Jervis Liang <arc... at gmail.com> wrote:
>
> > On Dec 22, 2:36 pm, cf29 <fcharlypil... at gmail.com> wrote:
>
> > > The goal is to control all the chess board with five queens that do
> > > not attack each other. I found "manually" many solutions to this
> > > problem (184 until now)
>
> > How did you find 184 solutions? Wolfram says there are 91 distinct
> > solutions for 5-queens on an 8x8 board with no two queens attacking
> > each other.
>
> >http://mathworld.wolfram.com/QueensProblem.html
>
> If I am not mistaken, the 92 solutions are for 8 queens on a 8x8 board
> with no queen attacking each other.

It's *91* distinct solutions to what appears to be *exactly* your
problem:

"""
Dudeney (1970, pp. 95-96) also gave the following results for the
number of distinct arrangements N_u(k,n) of k queens attacking or
occupying every square of an nxn board for which no two queens attack
one another (they are "not protected").
k queens	nxn	N_u(k,n)
1	2	1
1	3	1
3	4	2
3	5	2
4	6	17
4	7	1
5	8	91
"""



> On the same page they say that for 5 queens controlling all the board
> the number of solutions is 4860 but it is in the case that "every
> queen is attacked ("protected") by at least one other". The picture
> above shows a position where all queens are "safe" though.
>
> So my problem is how to find the solutions for 5 (FIVE) queens
> controlling ALL the board with NO queen being under attack. I think
> that a short visit to the problem at (http://www.cf29.com/design/
> dame5_eng.php) will make it crystal clear.
> And more precisely as I did already a part of the job (see the
> original post). How can I record solutions in a way that the function
> goes to the NEXT possible valid position? It is probably a basic thing
> but I am new to programming and it is not obvious for me. If squares
> are indexed from 0, the first solution I found is [0, 10, 20, 25, 35]
> and now how can I look for the next one,

ermmmm, the same way as you found the first one?

> record it in my solutions
> list

solutions_list.append(solution)




More information about the Python-list mailing list