"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>Background:
>The problem I'm trying to solve is.
>There is a 5x5 grid.
>You need to fit 5 queens on the board such that when placed there are
>three spots left that are not threatened by the queen.
I know this wasn't a contest, but here's my solutio
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] wrote:
>
>> The problem I'm trying to solve is.
>> There is a 5x5 grid.
>> You need to fit 5 queens on the board such that when placed there are
>> three spots left that are not threatened by the queen.
>
>when you're done with your hom
Sorry to bring this up again, but I decided to try to re-create the
program, using the 2d array.
However, I ran into a slight problem.
How will the permutation function have to be modified?
I'm having issues trying to figure out how it works, and how it would
need to be modified to use it correct
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 p
Thank you very much guys!
Just for clarification it wasn't homework, just extra credit :)
I can't beleive I didn't realize that I didn't clear the GLOBAL
variable :D
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
>> The problem I'm trying to solve is.
>> There is a 5x5 grid.
>> You need to fit 5 queens on the board such that when placed there are
>> three spots left that are not threatened by the queen.
>
> when you're done with your homework (?), you can
[EMAIL PROTECTED] wrote:
> The problem I'm trying to solve is.
> There is a 5x5 grid.
> You need to fit 5 queens on the board such that when placed there are
> three spots left that are not threatened by the queen.
when you're done with your homework (?), you can compare it with
Guido's solution:
It looks like a good start! Some tips-
- Index your arrays starting from 0 instead of 1. It will make life
easier (and it's the convention in most modern languages)
- Try a two dimensional array for the board representation? A list of
lists will do:
brd = [ [0] * 5 for i in xrange(5) ]
[EMAIL PROTECTED] wrote:
> The first named clearbrd() which takes no variables, and will reset the
> board to the 'no-queen' position.
(snip)
> The Code:
> #!/usr/bin/env python
> brd = [9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
> def clearbrd():
> brd = [9,0,0,0,0,0,0,0,0,0,0,0,0,
Background:
The problem I'm trying to solve is.
There is a 5x5 grid.
You need to fit 5 queens on the board such that when placed there are
three spots left that are not threatened by the queen.
My thinking:
I created a list, named brd, that represents the board.
I made it such that brd[1] would be
10 matches
Mail list logo