This function finds an empty location so that we can assign a number for that particular row and column.
(grid: Matrix)
| 61 | |
| 62 | |
| 63 | def find_empty_location(grid: Matrix) -> tuple[int, int] | None: |
| 64 | """ |
| 65 | This function finds an empty location so that we can assign a number |
| 66 | for that particular row and column. |
| 67 | """ |
| 68 | for i in range(9): |
| 69 | for j in range(9): |
| 70 | if grid[i][j] == 0: |
| 71 | return i, j |
| 72 | return None |
| 73 | |
| 74 | |
| 75 | def sudoku(grid: Matrix) -> Matrix | None: |