Skip to content

Instantly share code, notes, and snippets.

@avdg
Created May 14, 2011 16:36
Show Gist options
  • Save avdg/972364 to your computer and use it in GitHub Desktop.
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*
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
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