FunctionRacerProblemsRace

Fill the Sudoku

HardRecursionPython, JavaScript, TypeScript, Java, C++

grid is a Sudoku puzzle: 9 strings of 9 characters, the digits 1 to 9 and . for an empty cell. Fill every empty cell with a digit so that each row, each column and each of the nine 3 by 3 boxes holds the digits 1 to 9 exactly once.

The puzzle has exactly one solution. Return it in the same form, as 9 strings of 9 digits.

Example 1

grid ["....2.5..","..73...9.","...417...",".7.6..4..","24..5.6.3","5.8.....9","...9...4.","7....2.56","9....327."]
returns ["413829567","827365194","695417832","371698425","249751683","568234719","152976348","734182956","986543271"]

Every row, every column and every 3 by 3 box of the answer holds each digit once, and no given digit has changed.

Example 2

grid ["918235746","576149832","342687915","485321679","123976.58","769458123","237864591","694513287","851792364"]
returns ["918235746","576149832","342687915","485321679","123976458","769458123","237864591","694513287","851792364"]

A single cell is empty, and only one digit is missing from its row.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Recursion problems