Sudoku is a logic-based number puzzle where the objective is to fill a 9×9 grid with digits from 1 to 9, ensuring the following rules are met:
- Row Rule: Each row must contain all digits from 1 to 9 without repetition.
- Column Rule: Each column must contain all digits from 1 to 9 without repetition.
- Box Rule: The grid is divided into 9 sub-boxes (3×3 grids), and each sub-box must also contain all digits from 1 to 9 without repetition.
To check the 3×3 boxes in a Sudoku board, we need to ensure that no number appears more than once in any of the 9 sub-boxes. Each box can be uniquely identified by the tuple (r // 3, c // 3)
where r
and c
are the row and column indices.