hii everybody,
I have a weird problem with a program for solving sudoku puzzles. I am representing the puzzle as a list of lists of lists containing all the possibillities for a single square and my problem is that when I try to remove a single appearance of a number from a square, the number is removed from all the squares in the grid. I am using the .remove() function and I am not sure why it is behaving like that. Here is the code I am having trouble with...
def eliminate( grid, square, value ):
row = square[ 0 ]; col = square[ 1 ]
poss = grid[ row ][ col ]
if len( poss ) > 1:
poss.remove( value )
grid[ row ][ col ] = poss
# if len( poss ) == 1:
# fixValue( grid, square, poss[ 0 ] )
'square' is a tuple representing the ( row, column ) of the square
'grid' is the whole grid
'value' is the value to be removed from the possibillities for the current square
At the end when I try to print the grid all the squares are changed with the result for 'poss'
If you need other pieces of the code I'll post them here...