Testing the Sudoku Solver
Now that we have implemented the Sudoku solver algorithm using backtracking, let's test it with some sample puzzles.
To test the solver, we will create a few Sudoku puzzles with different levels of difficulty. We will pass these puzzles to the solveSudoku
function and check if the solver returns the correct solution.
Here's an example of a sample Sudoku puzzle:
TEXT/X-C++SRC
1vector<vector<int>> puzzle = {
2 {5, 3, 0, 0, 7, 0, 0, 0, 0},
3 {6, 0, 0, 1, 9, 5, 0, 0, 0},
4 {0, 9, 8, 0, 0, 0, 0, 6, 0},
5 {8, 0, 0, 0, 6, 0, 0, 0, 3},
6 {4, 0, 0, 8, 0, 3, 0, 0, 1},
7 {7, 0, 0, 0, 2, 0, 0, 0, 6},
8 {0, 6, 0, 0, 0, 0, 2, 8, 0},
9 {0, 0, 0, 4, 1, 9, 0, 0, 5},
10 {0, 0, 0, 0, 8, 0, 0, 7, 9}
11};