Skip to content
S-Daria edited this page May 31, 2021 · 10 revisions

The project is a sudoku solver. It solves the sudoku with input in file (examples are presented) using backtracking (and recursion).

In the project the grid is taken from the conditions file. An example of the grid used in the project:

0 7 0 5 0 0 2 0 0
0 0 0 0 0 7 8 0 4
3 8 1 0 0 6 0 9 5
0 0 8 0 0 2 5 0 0
5 9 2 6 0 3 1 4 8
0 0 4 8 0 0 9 0 0
6 1 0 9 0 0 4 2 7
8 0 7 1 0 0 0 0 0
0 0 3 0 0 5 0 8 0

The pseudo-code for the solver is next:

SOLVE(grid) {
  find an empty cell
  if there are no empty cells:
     return True

  for i:=1 to 9 do
      if it is safe to place i to empty cell:
          place i to empty cell
          if SOLVE(grid):
              return True
          else:
              make cell empty again
   return False
}
Clone this wiki locally