AdvancedChallenge 32 of 34

Sudoku validator

Write is_valid_sudoku(board) for a 9×9 grid of integers where 0 means empty. Return True if no row, column or 3×3 box contains a repeated digit 1–9. Empty cells never conflict.

Exercise

Sudoku validator

5 checks
def is_valid_sudoku(board):
    ...


board = [[5,3,0,0,7,0,0,0,0],[6,0,0,1,9,5,0,0,0],[0,9,8,0,0,0,0,6,0],[8,0,0,0,6,0,0,0,3],[4,0,0,8,0,3,0,0,1],[7,0,0,0,2,0,0,0,6],[0,6,0,0,0,0,2,8,0],[0,0,0,4,1,9,0,0,5],[0,0,0,0,8,0,0,7,9]]
print(is_valid_sudoku(board))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.