Skip to content

TomasPecinka/python-sudoku-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

python-sudoku-solver

Console-based python program which solves all kinds of sudoku boards using backtracking algorithm, which is a type of brute force searching algorithms.
Game board is represented by 9x9 matrix, blank fields are displayed as zeros.
The entire program is divided into 4 python functions:

  • print_board() - prints board to a console in more readable way than just list of lists
  • find_empty() - finds position where the number is 0, which means that the field is blank, function returns blank field coordinates in a python list [x_coordinate, y_coordinate]
  • validate_board() - checks if the board complies with the sudoku rules - if number is only used once in row, column, and subsquare
  • solve_board()
    • calls find_empty() to check if there are empty squares on the board, if no, the board is solved and function ends here
    • generate number from 1 to 9 and call validate_board() with this number, if it fits, the number is added to the board
    • recursively call function solve_board() again with updated parameter

      Image of Console

About

Console-based python program which solves (almost) all kinds of sudoku boards using backtracking algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages