I wanted to write a solver for Sudoku puzzles as a quick project and came up with this. It's an iterative solver that applies a combination of rules for candidate elimination and guessing with backtracking. It's far from perfect, but I've been able to achieve performance I'm happy with (ca. 0.01-0.1 seconds to solve a puzzle over my benchmark set, with typically <5 cells requiring guesses on difficult puzzles). For future improvement, I'd like to implement some more advanced candidate elimination rules to further reduce the amount of necessary guessing, but I've been able to optimize the highest touch operations (board validity checks, memory copies during backtracking) to a reasonable extent for Python.
To run:
uv sync
sudoku