Python: Recursive pass by value, 4 queens
<p>I'm trying to implement a backtracking algorithm, in Python, to solve the 4 queens problem. I have created a class Queens with the following:</p>

<pre><code>def __init__(self, board_size=4):
    self.board  = [[0 for i in xrange(0,board_size)] for i in xrange(0,board_size)];
</code></pre>

<p>But when I implement the recursive backtrack, due to pass by reference the board gets filled with 1s everywhere that has been visited.</p>

<pre><code>def backtrack(self, board, next_column):
            (algorithm here) ...
            board[i][column] = 1 ... #to indicate a placed queen
            self.backtrack(board, next_column + 1);
            (rest of algorithm)
</code></pre>

<p>I know that I can do </p>

<pre><code>new_board = copy.deepcopy(board);
</code></pre>

<p>Shallow copies wont work for higher dimensional arrays. 
Is there a better way of doing this, since I hear there are some problems with deepcopy?
Answers which suggest a different data structure other than a 2d list is also acceptable.</p>

<p>Thanks a lot</p>
