Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C, Write a program sudoku that (part 1) checks whether a proposed Sudoku solution is correct and (part 2) checks whether a partially-solved Sudoku

In C, Write a program sudoku that (part 1) checks whether a proposed Sudoku solution is correct and (part 2) checks whether a partially-solved Sudoku puzzle with one unknown square can be solved. sudoku takes a single argument, which is the path to a le containing a completed or almost-completed Sudoku puzzle. A completed Sudoku puzzle is a 99 matrix containing the digits 19, inclusive. The matrix is divided into nine 33 submatrixes, themselves arranged in a 33 square. A completed Sudoku puzzle is a correct solution if and only if it has the following properties: Each digit occurs exactly once in each row (that is, no row contains any digit more than once. Each digit occurs exactly once in each column. Each digit occurs exactly once in each submatrix.An almost-completed Sudoku puzzle is similar, except that one or two elements are unspecied. This problem has two parts. For part one (6 points), you must be able to check whether a completed Sudoku puzzle contains a correct solution. For part two (6 points), you must be able to determine whether an almost-completed Sudoku puzzle is solvable. The remaining 4 points are for style. Both parts are submitted as a single program. You will receive partial credit if your program correctly handles part one. 1.7.1 Correctness checking The input le contains a completed Sudoku puzzle. The puzzle is given on nine lines, each of which contains nine digits without any separation. Note that the digit 0 will not occur. The input le file1.txt corresponding to the puzzle above would contain:

534678912

672195348

198342567

859761423

426853791

713924856

961537284

287419635

345286179

When given such a le, sudoku must determine whether the completed puzzle is a correct solution (meaning it satises the three properties). If so, it prints correct. Otherwise, it prints incorrect. If the input le does not exist, is not readable, or does not follow the format specied here, sudoku may print error. 5 Usage $ ./sudoku file1.txt correct 1.7.2 Solvability checking The input le contains an almost-completed Sudoku puzzle. The format is the same as abovenine lines with nine characters eachexcept that up to two of the characters may be spaces instead of digits. The spaces indicate that the digit for that element is unspecied. The input le file2.txt contains an almost-completed puzzle with two unknown entries: 435269781

682571493

1978345 2

26195347

374682915

951743628

519 26874

248957136

763418259 If the input le contains an almost-completed puzzle, sudoku must determine whether the puzzle can be solved. If the puzzle has unspecied entries, can they be replaced by a digits such that the completed puzzle is a correct solution? If so, sudoku prints solvable. Otherwise, it prints unsolvable. If the puzzle contains no unspecied entries (that is, it is a completed puzzle), sudoku will print correct or incorrect as before. If the input le does not exist, is not readable, does not follow the format specied above, or contains more than two unspecied elements, sudoku may print error. Usage $ ./sudoku file2.txt solvable

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago