#C6557. Validate Sudoku Solution
Validate Sudoku Solution
Validate Sudoku Solution
Given a completed (9\times9) Sudoku grid, verify whether it is a valid solution. A valid Sudoku grid satisfies the following conditions:
- Each row contains the digits 1 to 9 without any repetition.
- Each column contains the digits 1 to 9 without any repetition.
- Each of the nine \(3\times3\) sub-grids contains the digits 1 to 9 without any repetition.
The grid is provided via standard input as 9 lines, each line containing 9 space-separated integers. Output a single line with True
if the grid is a valid Sudoku solution, or False
otherwise.
inputFormat
The input consists of 9 lines. Each line contains 9 integers separated by spaces, representing one row of the Sudoku grid.
outputFormat
Output a single line: True
if the Sudoku grid is valid, or False
if it is not.## sample
5 3 4 6 7 8 9 1 2
6 7 2 1 9 5 3 4 8
1 9 8 3 4 2 5 6 7
8 5 9 7 6 1 4 2 3
4 2 6 8 5 3 7 9 1
7 1 3 9 2 4 8 5 6
9 6 1 5 3 7 2 8 4
2 8 7 4 1 9 6 3 5
3 4 5 2 8 6 1 7 9
True