An interactive desktop application for creating, solving, and generating Sudoku puzzles using Python and Tkinter. This project offers a user-friendly graphical interface and a robust backtracking algorithm to solve puzzles of varying dimensions, making it ideal for Sudoku enthusiasts and learners.
🔢 Dynamic Grid Creation
Supports Sudoku grids of sizes 4x4, 9x9, and 16x16. Automatically adjusts the grid layout to match the selected size.
🧩 Sudoku Puzzle Solver
Solves Sudoku puzzles using an efficient backtracking algorithm. Detects and alerts users if a solution is not possible. Distinguishes solver-filled cells with a color-coded highlight.
🎲 Puzzle Generator
Generates Sudoku puzzles with random placements and unique solutions. Leaves some cells blank for the user to solve.
✅ Validation and Feedback
Ensures the grid size is valid (only perfect square dimensions allowed). Validates user inputs to ensure numbers fall within the valid range. Provides error messages for invalid grids or unsolvable puzzles.
🔄 Grid Management Allows users to reset the grid at any time. Clears user inputs and solver-generated values for a fresh start.
Prerequisites
Python 3.8 or higher. Tkinter library (comes pre-installed with Python on most platforms).
Steps
Clone the repository:
git clone https://github.com/yourusername/sudoku-solver-generator.git cd sudoku-solver-generator
Run the program:
python sudoku_solver.py
- Launch the Application: Run the script to open the Sudoku Solver and Generator GUI.
- Set Grid Dimensions: Enter a grid size (4, 9, or 16) in the input box.
- Create a Grid: Click the "Create Grid" button to generate an empty Sudoku grid.
- Generate a Puzzle: Click "Generate Sudoku" to create a new puzzle with pre-filled values.
- Solve a Puzzle: Enter numbers into the grid, then click "Solve Puzzle" to see the solution.
- Clear the Grid: Click "Clear Grid" to reset the board.
sudoku-solver-generator/ │ ├── sudoku_solver.py # Main application script ├── README.md # Project documentation
Python: For core logic and algorithm implementation. Tkinter: For creating the graphical user interface. Random Module: For generating randomized puzzles.
-
Backtracking Algorithm The core of the solver is a backtracking algorithm that systematically tries numbers in empty cells, backtracking when conflicts arise, until a solution is found or deemed impossible.
-
Puzzle Generator A complete puzzle is generated and then randomized numbers are removed while ensuring the puzzle retains a unique solution.
Coming soon...
Add difficulty levels (Easy, Medium, Hard) by varying the number of pre-filled cells. Implement hints to guide users during solving. Enhance the UI with grid-line separation for better sub-grid visibility. Add save/load functionality for puzzles.
Contributions are welcome! Feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch: git checkout -b feature-name.
- Make your changes and commit: git commit -m "Add feature".
- Push to the branch: git push origin feature-name.
- Open a pull request.
Inspired by the classic Sudoku puzzle. Thanks to the Python and open-source communities for their amazing tools and resources! Enjoy solving Sudoku puzzles! 🎉