#include #include #include #include #include using namespace std; struct Grid { vector > gameboard; // Holds puzzle. }; class Sudoku { public: // Precondition: input file exists or input numbers are valid. // Postcondition: an array of 81 integers is created - the Sudoku board. void createGrid(Grid &gameboard); // Precondition: createGrid(...) has been called. // Postcondition: Solution to puzzle is displayed if possible - exits if not possible. int Solve(int loc, int loc2, int num, Grid &gameboard); private: // Precondition: A valid location is passed. // Postcondition: Moves to next empty space. void place_next(int &loc, int &loc2, Grid *pboard); // Counts number of correct entries to verify when puzzle complete. int counter; // Precondition: A valid location and attempted value are input. // Postcondition: Returns whether or not this value already exists in same row. bool row_check(int loc, int val, Grid *pboard); // Precondition: A valid location and attempted value are input. // Postcondition: Returns whether or not this value already exists in same column. bool column_check(int loc2, int val, Grid *pboard); // Precondition: A valid location and attempted value are input. // Postcondition: Returns whether or not this value already exists in same location in other square. bool square_check(int loc, int loc2, int val, Grid *pboard); // Precondition: Puzzle is solveable. // Postcondition: Prints out solution. void print_solution(Grid *pboard); };