Description

This is a Python-based Sudoku game that is implemented entirely on TKinter (not pygame) that allows users to solve puzzles, generate new Sudoku boards, and even check the validity of their solutions. The game is interactive, with a graphical user interface (GUI) for ease of use, making it accessible to both beginners and Sudoku enthusiasts.

The program employs an algorithm that mimics the penciling strategy used to solve Sudoku puzzles in real life, allowing it to solve any Sudoku board. While this approach is quite effective, it wasn't my original idea.

Initially, I tried solving Sudoku using a basic backtracking strategy with simple while loops. After testing it on various input boards, I quickly realized that my algorithm was inefficient, with some basic puzzles taking minutes, or even hours, to solve.

I decided to revisit the algorithm, still sticking with the backtracking approach but this time utilizing recursion. Although it was faster than my original attempt, some boards still took several minutes to solve.

After more research, I stumbled upon an advanced algorithm called Dancing Links, developed by Professor Donald Knuth. This algorithm can solve any Sudoku board with lightning speed, while also detecting unsolvable boards and identifying multiple solutions when present. A Sudoku solver using this powerful algorithm can be found on this website, and its main logic file is available here.

However, implementing the Dancing Links algorithm on my own proved to be quite challenging. I spent many hours trying to grasp its concepts by reading Professor Knuth’s book The Art of Computer Programming (Fascicle 5: Mathematical Preliminaries Redux; Introduction to Backtracking; Dancing Links), but due to time constraints, I couldn't fully comprehend it.

Eventually, I discovered a more accessible algorithm, which I mentioned at the start, from a LeetCode user named "Ov8CfeJ3Su." Their algorithm is much easier to understand and implement. You can find it here. The core logic of my program is based on their work, while the rest of the implementation was done by me.

  • Interactive GUI: Play Sudoku using an intuitive graphical interface.
  • Sudoku Board Generation: Generate new Sudoku boards with varying difficulty levels.
  • Solution Checker: Check if the current board configuration is valid and adheres to Sudoku rules.
  • Showing hints when the player is stuck
  • Timer for tracking how long it takes to solve a puzzle
  • A leaderboard for tracking top scores
  • Show in real-time how the algorithm changes each cell using backtracking when solving
  • Dancing Links implementation + IRL sudoku advanced techniques such as finding Hidden Singles, Hidden Pairs, Swordfish, X-wing, Y-wing, etc. to maxmiize solving runtime