Question
PROGRAMMING IN C Sudoku is popular puzzle game. See http://www.sudoku.com. It is 9x9 grid with numbers so that each row, column and 3x3 section contains
PROGRAMMING IN C
Sudoku is popular puzzle game. See http://www.sudoku.com. It is 9x9 grid with numbers so that each row, column and 3x3 section contains all the digits between 1 and 9. This problem ask you to read a given 9X9 number grid containing only numbers between 1 and 9, and report weather or not each row, column and 3x3 section satisfies the requirement or not. For each row, column and 3x3 section, the program should report 0 if it does not satisfy the requirement, report 1 if it does. That is your program should report 3 lines, each lines has sequence of 9 0s or 1s.
Each 1 in the first line means row 1 9 all satisfies the requirement.
Each 1 in the second line means col 1 9 all satisfies the requirement.
Each 1 in the third line means all 9 section satisfies the requirement
The row number and column number should follow the order below:
row
1 2 3 6 7 8 9 4 5 1
5 8 4 2 3 9 7 6 1 2
9 6 7 1 4 5 3 2 8 3
3 7 2 4 6 1 5 8 9 4
6 9 1 5 8 3 2 7 4 5
4 5 8 7 9 2 6 1 3 6
8 3 6 9 2 4 1 5 7 7
2 1 9 8 5 7 4 3 6 8
7 4 5 3 1 6 8 9 2 9
col 1 2 3 4 5 6 7 8 9
3X3 section numbers should follow the following order:
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
For example: here is a txt file sudoku.txt with 9x9 numbers. Each number is from 1-9. Each row, column and 3x3 section (total of 9 of them) has each number of 1-9 once and only once.
1 2 3 6 7 8 9 4 5
5 8 4 2 3 9 7 6 1
9 6 7 1 4 5 3 2 8
3 7 2 4 6 1 5 8 9
6 9 1 5 8 3 2 7 4
4 5 8 7 9 2 6 1 3
8 3 6 9 2 4 1 5 7
2 1 9 8 5 7 4 3 6
7 4 5 3 1 6 8 9 2
./sudoku < sudoku.txt
111111111
111111111
111111111
Here is another example: sudoku_badsquare.txt, which all rows and columns satisfy the requirement, but section 1-6 does not satisfy the requirement.
3 7 2 4 6 1 5 8 9
5 8 4 2 3 9 7 6 1
9 6 7 1 4 5 3 2 8
1 2 3 6 7 8 9 4 5
6 9 1 5 8 3 2 7 4
4 5 8 7 9 2 6 1 3
8 3 6 9 2 4 1 5 7
2 1 9 8 5 7 4 3 6
7 4 5 3 1 6 8 9 2
./sudoku < sudoku_badsquare.txt
111111111
111111111
000000111
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started