Project 4: Sodoku Solver
Deadline: 11:30am, October 19th
Read this document carefully and completely before you attempt to solve programming project 4.
It is a popular logic-based number placement game. The aim of the puzzle is to enter a
numerical digit from 1 through 9 in each cell of a 99 grid made up of 33 sub grids (called
boxes). The game starts with various digits given in some cells (the givens). When
finished, each row, column, and 3x3 regions must contain all 9 digits with no repetition.
Completing the game requires patience and logical ability. Here is an interesting site if you
would like to try and play the game http://www.dkmsoftware.com/sudoku/
There are 3 simple rules you must follow when playing Sudoku. Fill in the grid so that
1) every row
2) every column
3) ever 3x3 box
contains the digits 1 through 9.
This is a row that is 9 cells wide. A filed row must have one of each digit. That
means that each digit appears
only once in the row. There are
9 rows in the grid, and the same applies to each of them.
This is a column, 9 cells tall. A filled column consists of having one of each
digit just like the row. This means each digit will appear only once in the
column. There are 9 columns in a typical Sudoku grid, and the same
applies to each of them.
This is a box containing 9 cells in a 3x3 layout. A filled box consists of
having one of each digit just like the rows and columns.
This means that each digit appears only once is in the
box. There are 9 boxes in a typical Sudoku grid, and the
same applies to each of them.
You will notice that the maroon colored digits are the “givens” and the gray shaded digits are
the possible digits that can be added to the row, column or grid to satisfy the 3 rules above.
• bool Solve ():
o You will implement a solve() function to solve your Sudoku grid. Your solve
function should a recursive function, meaning that this function will call itself
continuously until the game has been solved. Each recursive function will try
different values applying each of the 3 rules and return a bool back to itself.
If a FALSE is returned then the puzzle cannot be solved, and if a TRUE is
returned the puzzle is solved. When your solve function has completed
solving the game, your program will save the contents of solved or unsolved
• Save ():
o The save function will print the contents of solved Suduko board to the
screen followed by solved. If the game cannot be solved then your program
should print out what it had completed up until the point it determined the
game is unsolvable followed by unsolved.
• ostream operator
o You will want to overload an ostream’s operator so that you can display a
user defined object. Here is an example of overloading,
• You will also need to implement and default constructor, a copy constructor, a
destructor and an assignment operator for your objects.
Your projects directory structure:
• The same as described in project 3. You must comment your code using Doxygen.
We will read you code using Doxygen generated documentation.
• Running make should produce the prj_4 executable under the bin directory. Running
‘doxygen’ with the included Doxyfile should produce documentation under your
• Your project should be up to date on the svn server for checkout when completed
• svn checkout https://svn.cs.fsu.edu/repos/teamXY/prj_4
o Will be available shortly after midterm
• Familiarizing yourself with the game and its rules at one of the websites listed above.
• Read in input from file and populate your data structure to hold the values.
o Consider using a 2D array and for each element in the array have a vector.
Once you understand the rules, you will see that for every blank spot in the
Sudoku board you will have a possible of 1-9 candidates to try. And whether
those candidates work or not will depend upon the three Sudoku rules. So
your vector will contain initially values 1 – 9 and as your populate your board
you will update those values in the candidate vector for each cell in your
• Your solve function will be a recursive function that will call itself and try new values
for each spot in the Sudoku board until all of the 3 rules are satisfied.
o Consider perhaps making copies of your Sudoku objects and updating the
candidate vectors of the board to reflect the new number that you have
Input and Output Format:
• Your program should take in input file containing the rows of initial information to
populate your sudoku game to be solved.
• usr@linrprog4:~/prj_4/bin/ prj_4 sudoku_input1
o Your input file should be in the following format.
• Your program should output either the solved or the unsolved sudoku.
Puzzles: 1, Solved 1, Unsolved: 0
Parece que tem um bloqueador de anúncios ativo. Ao listar o SlideShare no seu bloqueador de anúncios, está a apoiar a nossa comunidade de criadores de conteúdo.
Atualizámos a nossa política de privacidade.
Atualizámos a nossa política de privacidade de modo a estarmos em conformidade com os regulamentos de privacidade em constante mutação a nível mundial e para lhe fornecer uma visão sobre as formas limitadas de utilização dos seus dados.
Pode ler os detalhes abaixo. Ao aceitar, está a concordar com a política de privacidade atualizada.