Question: c code be done in C++ Please Use this Header File only. Changes may be applicable. // this is the header file class sudoku {

c code be done in C++ Please Use this Header File only.c

code be done in C++

Please Use this Header File only. Changes may be applicable.

// this is the header file class sudoku { public: sudoku(); //default constructor //Postcondition: grid is initialized to 0

sudoku(int g[][9]); //constructor //Postcondition: grid = g

void initializeSudokuGrid(); //Function to promt the user to specify the numbers of the //partially filled grid. //Postcondition: grid is initialized to the numbers // specified by the user.

void initializeSudokuGrid(int g[][9]); //Function to initialize grid to g //Postcondition: grid = g;

void printSudokuGrid(); //Function to print the sudoku grid.

bool solveSudoku(); //Funtion to solve the sudoku problem. //Postcondition: If a solution exits, it returns true, // otherwise it returns false. bool findEmptyGridSlot(int &row, int &col); //Function to determine if the grid slot specified by //row and col is empty. //Postcondition: Returns true if grid[row][col] = 0;

bool canPlaceNum(int row, int col, int num); //Function to determine if num can be placed in //grid[row][col] //Postcondition: Returns true if num can be placed in // grid[row][col], otherwise it returns false.

bool numAlreadyInRow(int row, int num); //Function to determine if num is in grid[row][] //Postcondition: Returns true if num is in grid[row][], // otherwise it returns false.

bool numAlreadyInCol(int col, int num); //Function to determine if num is in grid[row][] //Postcondition: Returns true if num is in grid[row][], // otherwise it returns false.

bool numAlreadyInBox(int smallGridRow, int smallGridCol, int num); //Function to determine if num is in the small grid //Postcondition: Returns true if num is in small grid, // otherwise it returns false.

private: int grid[9][9]; };

Solving Sudoku Puzzles (sudoku.h; sudokulmp.cpp: sodokuDriver.cpp) The goal of Sudoku is to assign digits to the empty cells so that every row. column, and sub-grid contains exactly one instance of the digits from 1 to 9. The starting cells are assigned to constrain the puzzle such that there is only one way to finish it. Sudoku solvers pride themselves on the fact that there is no need to guess to solve the puzzle, the careful application of logic will lead you to the solution. Some recursive backtracking pseudocode: Find row, we find the first empty grid slot. Next we find the first number, between 1 to 9, that can be placed in this slot. Before placing a number in an empty slot, we must check that the number does not appear in the row, column, and the 3 x 3 grid containing the slot. After placing a number the first empty slot, we find the next empty slot and try to place a number in that slot. If a number cannot be placed in a slot, then we must backtrack to the previous slot, where the number was placed place a different number, and continue. If we arrive at a slot where no number can be placed, then the Sudoku problem has no solutions. You are given the header file a, you need to write an implementation file and a driver file. You can modify the sudoku class (header file) as you wish. You can copy the partially filled sudoku grid of the given sample outputs to test your program. Three Sample Outputs Sample Output 2 Sample Output 1 Sample Output 3 Enter partially filled sudoku grid: Enter partially filled sudoku grid: 080170003 020000009 090030540 004090000 000703000 000010400 61 9080050 700000080 200064010 Enter partially filled sudoku grid: 00300 2000 260094000 008530006 056000190 000000000 021000570 600025400 000910067 008600900 grid before solution: 003002000 2600 94000 008530006 056000190 000000000 021000570 600025 400 000910067 008600900 1956 72438 208043750 000000020 000091305 004000100 5093 60000 051000000 042150809 000024000 grid before solution: 1956 72438 208043750 000000020 000091305 004000100 509360000 051000000 04215 0809 000024000 Erid before solution: 080170003 020000009 090030548 004090000 000703000 000010400 619080050 700000080 2000 64010 Solution Solution:- No solutions 485179623 326458 179 107632548 1956 72438 263943751 14 73518026

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!