Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Java-based Sudoku generator and solver. The program generates a valid Sudoku puzzle, allows users to solve it interactively, and provides the solution upon request.

License

Notifications You must be signed in to change notification settings

Leshoraa/Sudoku-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

Sudoku Generator and Solver

This repository contains a Java-based Sudoku generator and solver. The program generates a valid Sudoku puzzle, allows users to solve it interactively, and provides the solution upon request.

Features

  • Generates a valid Sudoku puzzle.
  • Interactive user input for solving the puzzle.
  • Provides the solution when requested.
  • Ensures no duplicate numbers in rows, columns, or subgrids.

How to Use

  1. Clone the repository:

    git clone https://github.com/Leshoraa/Sudoku-java.git
    cd Sudoku-java
  2. Compile the Java program:

    javac Sudoku.java
  3. Run the program:

    java Sudoku
  4. Follow the prompts:

    • The program will display the generated Sudoku puzzle.
    • You can choose to solve the puzzle yourself or see the solution.
    • If you choose to solve it yourself, input coordinates and numbers in the format A1 5.
    • To see the solution at any time, input bot.

Example

 A B C D E F G H I 
 -----------------------
 1 | 3 . . | . . 4 | 6 . 8 |
 2 | 2 . . | 1 . . | . . 5 |
 3 | 8 . . | 9 5 3 | . 2 4 |
 -----------------------
 4 | 1 5 . | . . 7 | 9 4 . |
 5 | . 2 3 | 8 6 . | . 1 . |
 6 | . . 9 | . 4 1 | 2 8 3 |
 -----------------------
 7 | 5 . 2 | . . 8 | . . . |
 8 | 9 . . | 7 1 . | . 3 . |
 9 | . . 1 | . 3 2 | 4 5 . |
 -----------------------
Solve by yourself? (y/n): y
Input coordinate and number (ex: A1 5): A1 3
Input coordinate and number (ex: A1 5): bot
Solution:
 A B C D E F G H I 
 -----------------------
 1 | 3 1 5 | 6 7 4 | 6 9 8 |
 2 | 2 6 4 | 1 8 9 | 7 3 5 |
 3 | 8 9 7 | 9 5 3 | 1 2 4 |
 -----------------------
 4 | 1 5 8 | 2 3 7 | 9 4 6 |
 5 | 4 2 3 | 8 6 5 | 7 1 9 |
 6 | 7 6 9 | 4 4 1 | 2 8 3 |
 -----------------------
 7 | 5 3 2 | 4 9 8 | 6 7 1 |
 8 | 9 8 6 | 7 1 2 | 5 3 2 |
 9 | 6 4 1 | 5 3 2 | 4 5 7 |
 -----------------------

License

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

About

Java-based Sudoku generator and solver. The program generates a valid Sudoku puzzle, allows users to solve it interactively, and provides the solution upon request.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /