https://github.com/adityasworks/sudoku-solver
Sudoku Solver using Backtracking method in pyhton
https://github.com/adityasworks/sudoku-solver
Last synced: 10 months ago
JSON representation
Sudoku Solver using Backtracking method in pyhton
- Host: GitHub
- URL: https://github.com/adityasworks/sudoku-solver
- Owner: AdityasWorks
- Created: 2024-06-16T07:28:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T07:38:11.000Z (almost 2 years ago)
- Last Synced: 2025-01-17T04:12:57.249Z (over 1 year ago)
- Language: Python
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sudoku Solver
This Python script solves a Sudoku puzzle using a backtracking algorithm.
## Example Sudoku Board
```python
board = [
[5, 3, 0, 0, 7, 0, 0, 0, 0],
[6, 0, 0, 1, 9, 5, 0, 0, 0],
[0, 9, 8, 0, 0, 0, 0, 6, 0],
[8, 0, 0, 0, 6, 0, 0, 0, 3],
[4, 0, 0, 8, 0, 3, 0, 0, 1],
[7, 0, 0, 0, 2, 0, 0, 0, 6],
[0, 6, 0, 0, 0, 0, 2, 8, 0],
[0, 0, 0, 4, 1, 9, 0, 0, 5],
[0, 0, 0, 0, 8, 0, 0, 7, 9]
]
```
## Functions
- Print_Board(bo): Prints the Sudoku board in a readable format.
- find_Empty(bo): Finds an empty cell (represented by 0) in the board.
- valid(bo, num, pos): Checks if placing a number num at position pos is valid according to Sudoku rules.
- solve(bo): Solves the Sudoku puzzle using backtracking.
## Usage
1. Clone Repository
```bash
git clone https://github.com/yourusername/sudoku-solver.git
```
2. Modify the "Board" variable
3. Run the Solver:
```bash
python Solver.py
```