64
edits
Changes
m
'''<h4>Sudoku Solver by Matt B.'''</h4>
''Easy puzzle''<h6>Running program</h6>
'''<h6>Test Case'''</h6>
'''<h6>Analysis'''</h6>
''<h5>Hard puzzle''</h5> <h6>Running program</h6>
'''<h6>Analysis'''</h6>
→Assignment 1
=== Assignment 1 ===
Sudoku solver is a program that solves a sudoku puzzle. The user can input an existing file and have the program solve this, or can manually enter values to be solved. The sudoku puzzle is 9x9 in size. The data needs to be in a specific format for the program to work. There are 9 rows of values, with each cell/element in the row needing to be separated by a space. A value of 0 tells the program to solve this value.
<h5>Easy puzzle</h5>
To compile the program, open the terminal and go to the projects directory
9 2 5 6 8 7 3 4 1
To profile the program, run this command.
The analysis reveals that the program took no time in solving this puzzle. However, the function checkRow and checkColumn were called the most. These two functions are used for checking whether the row and columns are correct. For a deeper analysis, a harder puzzle must be used.
For the hard puzzle, below is the input file as well as the result
4 7 2 3 1 9 5 6 8
8 6 3 7 4 5 2 1 9
<h6>Test Cases</h6>
The profiling results are
[6] checkSquare(int, int, int) [20] __static_initialization_and_destruction_0(int, int) [3] placeNum(int, int)
With a harder puzzle, the time for the program to solve the puzzle increased significantly. The total time to complete this puzzle was 17.13 seconds. The program spends almost half of its running time checking if the row is correct, and another 18% of its time checking whether the column is correct. This program contains thousands of calls to check the row and column values, this is why the program would be excellent project for parallelizing.