FunctionRacerProblemsRace

Finished Sudoku

HardNumPyPython

grid is a filled 9 by 9 board of digits 1 to 9. Return True if every row, every column and each of the nine 3 by 3 boxes holds all nine digits. No loops: for and while are not allowed.

Example 1

grid [[1,2,3,4,5,6,7,8,9],[4,5,6,7,8,9,1,2,3],[7,8,9,1,2,3,4,5,6],[2,3,4,5,6,7,8,9,1],[5,6,7,8,9,1,2,3,4],[8,9,1,2,3,4,5,6,7],[3,4,5,6,7,8,9,1,2],[6,7,8,9,1,2,3,4,5],[9,1,2,3,4,5,6,7,8]]
returns true

Each row is the one above it moved three places, and the three bands are offset by one more, so no row, column or box repeats a digit.

Example 2

grid [[1,2,3,4,5,6,7,8,9],[2,3,4,5,6,7,8,9,1],[3,4,5,6,7,8,9,1,2],[4,5,6,7,8,9,1,2,3],[5,6,7,8,9,1,2,3,4],[6,7,8,9,1,2,3,4,5],[7,8,9,1,2,3,4,5,6],[8,9,1,2,3,4,5,6,7],[9,1,2,3,4,5,6,7,8]]
returns false

Every row and every column has all nine digits, but the top-left box holds 1, 2, 3, 2, 3, 4, 3, 4, 5.

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 NumPy problems