Solve a four-by-four Sudoku
Solve a valid 4x4 Sudoku using digits 1 through 4, zeros as blanks, and 2x2 boxes. Return a solved new matrix or None if unsatisfiable. For multiple solutions choose the first from row-major blanks and ascending digits.
row = {1, 2}
column = {2, 3}
box = {1, 3}
print(set(range(1, 5))-(row | column | box))Reason about the state
Choose the first blank, try digits absent from its row, column and box, and backtrack after a failed suffix. Work on a copy so the original puzzle survives. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Solve a valid 4x4 Sudoku using digits 1 through 4, zeros as blanks, and 2x2 boxes. Return a solved new matrix or None if unsatisfiable. For multiple solutions choose the first from row-major blanks and ascending digits.
The explanation opens here once every check passes.