Hello, does anyone know how to do this problem?
Try to write a program to check if a generalized sudoku board is completed correctly or not.
It is considered that a table is correctly completed if there are no duplicate values on rows, columns or groups (squares).
Input data:
Unfortunately, the size of the board is not always the same, it being read from the keyboard at the beginning of the program, in the format:
line_number number_columns no_groups
Then enter from the keyboard the contents of each cell of the sudoku board, in the format:
line_number_column column_group number effective_value
Output data:
1 will be displayed if the board is correct, or 0 if not.
mentions:
The groups cannot overlap and are all the same size.
The value is just a natural number.
It is guaranteed that there are at least 2 rows, 2 columns, 2 groups.
The number of the row, column, group, starts from 0.
Example:
(comments are for clarity, they are not entered at the entrance)
4 4 4
0 0 0 1
0 1 0 2
1 0 0 3
1 1 0 4
// so far it was the first square
0 2 1 3
0 3 1 4
1 2 1 5
1 3 1 6
// so far the 2nd square
2 2 3 7
2 0 2 5
3 1 2 0
2 3 3 8
3 2 3 1
2 1 2 6
3 0 2 9
3 3 3 2
// last 2 mixed squares
the sudoku matrix would be: (4x4 with 4 groups)
1 2 | 3 4
3 4 | 5 6
5 6 | 7 8
9 0 | 1 2
this table is correct, having no duplicates either on the line, or on the column, or on the group.
Example of incorrect table:
1 1 | 3 4
3 4 | 5 6
5 6 | 7 8
9 0 | 1 2
line 0 has “1” doubled
1 2 | 3 4
1 4 | 5 6
5 6 | 7 8
9 0 | 1 2
column 0 has “1” doubled
1 2 | 3 4
3 4 | 5 6
5 6 | 7 8
9 0 | 1 7
group 3 has “7” doubled.
!! This is only 1 test, in total there are 5 to correct the problem.