This repository contains a Sudoku solver implemented in C++. The solver uses a backtracking algorithm to find a solution to a given Sudoku puzzle. It is capable of solving puzzles of varying difficulty levels.
The Sudoku solver program reads a Sudoku board, solves it using a backtracking algorithm, and prints the solved board. The Sudoku board is represented as a 9x9 grid where 0
denotes an empty cell.
- Validation: The
isValid
function checks if placing a number in a specific cell is valid according to Sudoku rules. - Solving: The
solveSudoku
function uses recursion and backtracking to fill the board with numbers. - Printing: The
printBoard
function formats the board for easy reading.
To use the Sudoku solver:
- Clone this repository:
git clone https://github.com/yourusername/sudoku-solver.git
- Navigate to the project directory:
cd sudoku-solver
- Compile the code:
g++ -o sudoku_solver sudoku_solver.cpp
- Run the executable:
./sudoku_solver
The provided code includes a sample Sudoku puzzle. When you run the program, it will output the solved Sudoku board.