Skip to content

OracleBrain/Sudoku-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Prodigy_SD_04

PRODIGY_SD_04

# Sudoku Solver

This project is a Sudoku solver program that automatically solves Sudoku puzzles. It takes an input grid representing an unsolved Sudoku puzzle and uses backtracking or other suitable techniques to fill in the missing numbers. Once solved, the program displays the completed Sudoku grid.

## Features

- **Automatic solving:** The program automatically solves Sudoku puzzles.
- **Backtracking:** It uses backtracking or other suitable techniques to explore possible solutions and find the correct arrangement of numbers.
- **User feedback:** The program informs the user whether the Sudoku puzzle was solved successfully or if no solution exists.

## How to Use

1. Clone this repository to your local machine:

    ```sh
    git clone https://github.com/oraclebrain/sudoku-solver.git
    ```

2. Navigate to the project directory:

    ```sh
    cd sudoku-solver
    ```

3. Compile the Java program:

    ```sh
    javac SudokuSolver.java
    ```

4. Run the program:

    ```sh
    java SudokuSolver
    ```

5. Follow the on-screen instructions to see the solved Sudoku puzzle.

## Example

TASK 02 The program is represented by Jeegnasa Makwana Sudoku puzzle solved successfully! 5 3 4 6 7 8 9 1 2 6 7 2 1 9 5 3 4 8 1 9 8 3 4 2 5 6 7 8 5 9 7 6 1 4 2 3 4 2 6 8 5 3 7 9 1 7 1 3 9 2 4 8 5 6 9 6 1 5 3 7 2 8 4 2 8 7 4 1 9 6 3 5 3 4 5 2 8 6 1 7 9


## Code Overview

```java
public class SudokuSolver {
    public static void main(String[] args) {
        int[][] 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}
        };

        if (solveSudoku(board)) {
            System.out.println("TASK 02");
            System.out.println("The program is represented by Jeegnasa Makwana");
            System.out.println("Sudoku puzzle solved successfully!");
            printBoard(board);
        } else {
            System.out.println("No solution exists for the given Sudoku puzzle.");
        }
    }

    // Additional methods are omitted for brevity
}
  • The main method initializes the Sudoku puzzle grid, attempts to solve it using the solveSudoku method, and displays the solved puzzle if successful.
  • The solveSudoku method employs backtracking to explore possible solutions and find the correct arrangement of numbers.
  • Additional methods such as findEmptyCell, isValidMove, and printBoard are used to support the solving process.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Feel free to customize this `README.md` file further to suit your specific project needs or preferences.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages