All problems
Valid Sudoku Board
Problem
Return True if a partially filled 9 by 9 Sudoku board has no duplicate digits in any row, column or 3 by 3 box, where empty cells are the character dot.
Validate the three constraint types independently using sets. The board is considered valid regardless of whether it can be completed.
Hint
A 3 by 3 box index is (row // 3) * 3 + column // 3; validate rows, columns and boxes separately.
Test cases
case 1
in: [[["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4","…
expected: true
case 2
in: [[["8","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4","…
expected: false
case 3
in: [[["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],["5","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4","…
expected: false
case 4
in: [[["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4","…
expected: false
case 5
in: [[[".",".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".",".","."],[".","…
expected: true
Starter codePython
def is_valid_sudoku(board):
# Your code here
pass5 test cases · run your code against them in the editor