I'm trying to solve the Suduko problem by using a nested loop, and the zip function. When I run the initial list/matrix through my loop, it returns the correct values. However, when I run the zipped version of the list through the exact same loop (or a copy redefined as a separate function), it tells me it can't pop because there aren't any values in the list. I really don't understand why that is. By creating a new list with the the zip function, shouldn't it have values in it? And, when I run my code through the visual interpreter at: http://people.csail.mit.edu/pgbovine/python/tutor.html#mode=edit, it even displays the zipped matrix as a list.
I'd post the code here, but I know we're not supposed to do that.
asked 12 Mar '12, 10:38
I think i found your problem, I used the Python interpreter and it seems the ZIP function changes your (list of lists) matrix into a list of tuples.
Tuples are a different data structure in Python, represented by enclosing the element(s) in parenthesis. You might need to change your code to adapt to this.
Or you could use nested cycles (for) to transpose the matrix (I would assign this to a new variable) manually and run your code normally.
NOTE: Also you must take into accound that a 4x4 sudoku might have a number 5 or 0 in it, making it an incorrect sudoku square =)
answered 12 Mar '12, 13:49