hp
toc

Sudoku Solver

2016-08-06, post № 136

programming, Python, #666, #evil, #logic, #solve, #solving, #Web Sudoku

This program solves a given Sudoku.
It uses a simple strategy, looking at each box and determining those numbers that are not in its row, column and square. If that list has length 𝟣, the box’s number is determined.
After going through each box, the program generates child Sudokus in which the first empty box get filled with one of the possible numbers for that box. Sudokus with an error get eliminated.
Using this simple but effective strategy this program can solve hard Sudokus in under a second. As an example, I used Evil Puzzle 666 from Web Sudoku.
For more information on Sudokus, visit this Wikipedia entry.

sudoku-solver-1.png
Source code: sudoku-solver.py
Jonathan Frech's blog; built 2024/03/18 18:45:40 CET