Created
May 14, 2011 16:36
-
-
Save avdg/972364 to your computer and use it in GitHub Desktop.
Getting grid to 2d problem *solved: I had declared 9 rows on such a way it was stored as 1 row and 8 others that refers to them*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getSudoku(self): | |
sudoku = [[0] * 9 for x in range(9)] | |
for x, rows in enumerate(self.sudoku): | |
for y, cell in enumerate(rows): | |
if len(cell) == 1: | |
sudoku[x][y] = cell[0] | |
return sudoku |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expected grid: | |
890104020 | |
001067000 | |
000002951 | |
000890340 | |
300700100 | |
058036009 | |
000000504 | |
607500000 | |
480009036 | |
result: | |
[[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6], | |
[4, 8, 7, 5, 3, 9, 5, 3, 6]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment