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<<(std::ostream& out, const Sudoku& sudoku): A friend function that prints to the output stream out the current puzzle contents in a nicely formatted manner as seen in the example above. Instead of printing to std::cout, print to the passed output stream out and return it.

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!