Sudoku is a popular logic puzzle that uses a 9 by 9 array of squares that are organized into 3 by 3 subarrays. The puzzle solver must ﬁll in the squares with the digits 1 to 9 such that no digit is repeated in any row, any column, or any of the nine 3 by 3 subgroups of squares. Initially, some squares are ﬁlled in already and cannot be changed. For example, the following might be a starting conﬁguration for a Sudoku puzzle:
Screen Shot 2018-10-08 at 8.41.26 AM.png
Create a SudokuPuzzle that has :
– board—a 9 by 9 array of integers that represents the current state of the puzzle, where 0 indicates a blank square
– start—a 9 by 9 array of boolean values that indicates which squares in board are given values that cannot be changed and the following methods:
– CreateSudokuPuzzle(array,row,col)—a function that creates an empty puzzle Display(array,row,col)—
– Displays the puzzle that can be printed
– addInitial(array,row, col, value)—sets the given square to the given value as an initial value that cannot be changed by the puzzle solver
– addGuess(array,row, col, value)—sets the given square to the given value; the value can be changed later by another call to addGuess
– checkPuzzle—returns true if the values in the puzzle do not violate the restrictions getValueIn()—
– returns the value in the given square
– getAllowedValues()—returns a one-dimensional array of nine booleans, each of which corresponds to a digit and is true if the digit can be placed in the given square without violating the restrictions
– isFull—returns true if every square has a value
– reset—changes all of the nonpermanent squares back to blanks (0s)
Write a a program that creates a SudokuPuzzle and sets its initial conﬁguration. Then use a loop to allow someone to play Sudoku. Display the current conﬁguration and ask for a row, column, and value. Update the game board and display it again. If the conﬁguration does not satisfy the restrictions, let the user know. Indicate when the puzzle has been solved correctly. In that case, both checkPuzzle and isFull would return true. You should also allow options for resetting the puzzle and displaying the values that can be placed in a given square.
*You may use diﬀerent functions than one deﬁned above.
For extra credit(20 points):
– Create a randomized Puzzle
– The user should be allowed to play multiple games and continue playing, until he wants to exit.