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 is_valid(grid, r, c, k): | |
| not_in_row = k not in grid[r] | |
| not_in_column = k not in [grid[i][c] for i in range(9)] | |
| not_in_box = k not in [grid[i][j] for i in range(r//3*3, r//3*3+3) for j in range(c//3*3, c//3*3+3)] | |
| return not_in_row and not_in_column and not_in_box | |
| def solve(grid, r=0, c=0): | |
| if r == 9: | |
| return True |