Movatterモバイル変換


[0]ホーム

URL:


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

Add sudoku solver#7103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Raghu0703 wants to merge2 commits intoTheAlgorithms:master
base:master
Choose a base branch
Loading
fromRaghu0703:add-sudoku-solver

Conversation

@Raghu0703
Copy link

Description

This PR adds a Sudoku Solver implementation using the Backtracking algorithm as requested in issue#6929.

Changes

  • AddedSudokuSolver.java insrc/main/java/com/thealgorithms/backtracking/

    • Implements backtracking algorithm to solve 9×9 Sudoku puzzles
    • IncludesisValid() method to verify Sudoku constraints (row, column, 3×3 subgrid)
    • IncludessolveSudoku() method with recursive backtracking logic
    • IncludesprintBoard() helper method for formatted output
    • Provides example usage inmain() method
  • AddedSudokuSolverTest.java insrc/test/java/com/thealgorithms/backtracking/

    • Tests solvable Sudoku puzzle with expected solution verification
    • Tests unsolvable Sudoku puzzle (invalid constraints)
    • Tests already solved Sudoku
    • Tests empty Sudoku board
    • Tests difficult Sudoku puzzle with fewer clues

Algorithm Details

Testing

✅ All new tests pass:mvn test -Dtest=SudokuSolverTest
✅ Verified with multiple Sudoku puzzles
✅ Code follows repository formatting standards
✅ Includes proper documentation and comments

Checklist

  • I have readCONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL

- Implements Kruskal's algorithm using Union-Find- Includes comprehensive unit tests- Time complexity: O(E log E)- Space complexity: O(V + E)FixesTheAlgorithms#7067
- Implements backtracking algorithm to solve 9x9 Sudoku puzzles- Includes isValid() method to check Sudoku constraints- Includes solveSudoku() method with recursive backtracking- Adds comprehensive unit tests covering multiple scenarios- Tests include solvable, unsolvable, empty, and difficult puzzles- Includes example usage in main method with formatted output- Documents time complexity O(9^m) and space complexity O(m)FixesTheAlgorithms#6929
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@DenizAltunkapanDenizAltunkapanAwaiting requested review from DenizAltunkapanDenizAltunkapan is a code owner

@yanglbmeyanglbmeAwaiting requested review from yanglbmeyanglbme is a code owner

@alxkmalxkmAwaiting requested review from alxkmalxkm is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@Raghu0703

[8]ページ先頭

©2009-2025 Movatter.jp