Skip to content

GauthamMu/SudokuHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧩 Sudoku Solver Assistant (Human-like Strategy)

This Python script is a human-style Sudoku solving assistant. It takes a Sudoku puzzle input (row by row) and attempts to reduce possibilities for each cell using logical deductions β€” mimicking how a person might approach solving a puzzle step by step.

πŸ“‹ Features

  • Input Sudoku manually via console (as 9 lines of 9 characters each)
  • Displays the Sudoku board before and after each solving phase
  • Performs constraint-based elimination:
    • βœ… Row checking
    • βœ… Column checking
    • βœ… Box (3Γ—3 subgrid) checking
  • Iterates through these checks until no more progress is made
  • Final output is a cleaned-up grid with only solved digits shown
  • Includes nicely formatted display output for better visualization

πŸ”§ How It Works

The script follows a simple rule-based logic:

  1. Row Checking: For each empty cell, eliminate numbers already present in the same row.
  2. Column Checking: Further reduce candidates based on the column.
  3. Box Checking: Finally, reduce based on the 3Γ—3 subgrid.
  4. Repeat the above checks in a loop until the board state no longer changes.
  5. Hint Remover: All remaining multi-digit candidates are removed for a clean final display.

It doesn’t use any brute-force or backtracking β€” just pure logical deductions like a human might attempt.

βœ… Example

Enter 1st row of Sudoku (no gaps between numbers!):53  7    
Enter 2nd row of Sudoku (no gaps between numbers!):6  195   
Enter 3rd row of Sudoku (no gaps between numbers!): 98    6 
...

Intermediate states will be printed, ending with something like:

Final sudoku:
 +-----------------+-----------------+-----------------+
 |  5   .   3  |  .   7   .  |  .   .   .  | 
 |  6   .   .  |  1   9   5  |  .   .   .  | 
 |  .   9   8  |  .   .   .  |  .   6   .  | 
...

πŸ§ͺ Testing

The script includes several commented-out test puzzles taken from newspapers, Sudoku magazines, and Wikipedia. Just uncomment any of them to use instead of live input.

πŸ› οΈ Requirements

  • Python 3.x
  • No external libraries needed (uses only copy for deep copying)

πŸ—‚οΈ File Structure

  • sudokuHelper.py β€” main script file
  • README.md β€” this file

πŸš€ Future Improvements

  • Implement logical strategies like:
    • Naked/hidden singles/pairs
    • Pointing pairs/triples
    • X-Wing/Swordfish
  • Optional GUI for better interaction
  • Web or mobile interface

πŸ“œ License

No.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages