A Sudoku solution is a 9 × 9 grid in which every row, every column and every 3 × 3 box contains the digits 1 to 9 exactly once. SudokuCheck reads the 81 numbers of a filled grid, row by row, and reports every wrong row, column and box (numbered from 1; boxes are numbered left to right, top to bottom), then the verdict.
Write rowIsValid, columnIsValid, boxIsValid(grid, top, left) and a helper mark(boolean[] seen, int digit) that records a digit and returns false if it is not 1–9 or was already seen. For a correct grid the program prints Valid solution. For the input
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 1 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
the program prints
Row 5 is wrong
Column 5 is wrong
Box 5 is wrong
Invalid solution: 3 problem(s)