Question: You are to create a C++ class called Sudoku. This class should be implemented in the Sudoku.h and Sudoku.cpp files. The public interface of this

You are to create a C++ class called Sudoku. This class should be implemented in the Sudoku.h and Sudoku.cpp files. The public interface of this class is as follows:

Sudoku(): Default constructor. Should initialize the object with an empty puzzle (81 zeroes).

void loadFromFile(std::string filename): Reinitializes the object with a new puzzle from the specified file. The passed string will be the relative path of the text file (e.g., "../txt/sudoku1-test.txt"). You may assume the input file has the specified format of nine rows of nine digits separated by a space, and the numbers represent a valid Sudoku puzzle. Note: It is recommended that you use the extraction operator to read in the values, as it will automatically skip all white spaces (blanks, newlines) for you.

bool solve(): The entry point for your solver. Returns true if a solution was found, otherwise returns false. If no solution was found, you may leave the puzzle in either (1) its initial state, or (2) the state when you determined no solution was possible.

bool equals(const Sudoku& other) const: Determines if two puzzles are equal. Two puzzles are equal if the values in each corresponding cell are the same.

std::ostream& operator

DO NOT add or remove any item in the public interface other than additional constructors or destructors (a destructor is not listed above, because our solution does not use any dynamic memory). You may add items in the private interface (e.g., helper functions).

Below is an example execution:

Enter puzzle text file (assumes file is in "txt" folder). Pressing  will run the file "sudoku-test1.txt". sudoku-test2.txt

You are to create a C++ class called Sudoku. This class should

Puzzle: 8 3 | 6 | 29 | 7 1 6 18 | 5 4 | 8 5| 9 7 46| 8 35 | 6 4 2 | 1 5 6 6 7 5 1 1 | 6 5 | 8 | 981 | 4 6 3 5 Solution: 8 4 3 5 2 9 7 1 6 9 7 6 | 3 1 8 | 5 2 4 1 5 2 | 7 64 | 3 9 8 3 1 5 2 4 6 | 9 8 7 7 8 9 | 1 3 5 | 6 4 2 2 6 4 | 8 9 7 | 1 3 5 +- 6 98 | 4 7 3 | 2 5 1 4 31 | 6 5 2 | 8 7 9 5 27 | 981 | 4 6 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!