Large algorithm issue -- 5x5 grid, need to fit 5 queens plus some squares

Felipe Almeida Lessa felipe.lessa at gmail.com
Thu Mar 16 12:29:01 EST 2006


Em Qui, 2006-03-16 às 09:20 +0100, Fredrik Lundh escreveu:
> when you're done with your homework (?), you can compare it with
> Guido's solution:
> 
>     http://svn.python.org/view/python/trunk/Demo/scripts/queens.py

Just a curiosity. Running the script as the site lists on my computer:

$ time python2.4 /tmp/queens.py -n 12
Found 14200 solutions.

real    0m14.177s
user    0m13.700s
sys     0m0.042s

Adding a "import psyco; psyco.full()" clause to the beginning of the
file:

$ time python2.4 /tmp/queens.py -n 12
Found 14200 solutions.

real    0m3.250s
user    0m3.003s
sys     0m0.012s

At least interesting...

Felipe.




More information about the Python-list mailing list