Question: COBOL This program will be named lab7b.cob and will read and process a file named lab7b-in.dat which will be located in the same directory as
COBOL
This program will be named lab7b.cob and will read and process a file named lab7b-in.dat which will be located in the same directory as the lab7b executable (so do not specify a path for the file in the Select statement). This file will consist of records, each record containing 9 digits. This file represents the contents of completed Sudoku puzzles and your program is to determine
whether or not each puzzle representation represents a valid solution. Each record in the file represents a row in the puzzle. Each block of 9 consecutive records will represent one puzzle.
For each puzzle, the program will display to the screen a easier to read representation of the puzzle, with pipes and dashes to separate each of the 3x3 blocks. It will then state whether or not the provided solution is valid or not, or the fact that the provided solution is incomplete (if incomplete, do not check to see if what was provided is valid or not). An incomplete solution is one where there are not 9 records, or if one of the records does not contain 9 digits. Each record will contain 9 characters.
An incomplete solution is one where there are not 9 records, and/or any record contains a space as one of the characters. When printing the puzzle, any spaces and/or missing rows are represented with #s.
An invalid solution is one that contains non-numeric characters (other than spaces) or contains all numbers but is not a valid solution according to the rules of Sudoku. The invalid characters are displayed as-is.
Use a 2-dimensional array to hold the puzzle contents for analysis.
Sample output (note the spacing on the puzzle representation):
Puzzle:
8 2 4 | 6 1 5 | 7 3 9
7 6 1 | 4 9 3 | 2 5 8
5 3 9 | 7 2 8 | 6 4 1
-------------------------
1 7 8 | 9 3 4 | 5 6 2
6 5 2 | 1 8 7 | 4 9 3
4 9 3 | 5 6 2 | 8 1 7
-------------------------
3 1 5 | 8 7 6 | 9 2 4
2 4 7 | 3 5 9 | 1 8 6
9 8 6 | 2 4 1 | 3 7 5
This is a valid solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
