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

Ben Cartwright bencvt at
Thu Mar 16 06:12:53 CET 2006

totalgeekdom at wrote:
> The first named clearbrd() which takes no variables, and will reset the
> board to the 'no-queen' position.
> 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,0,0,0,0,0,0,0,0,0,0,0,0,0]

clearbrd() isn't doing what you want it to.  It should be written as:

  def clearbrd():
      global brd
      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]



More information about the Python-list mailing list