Skip to main content

Solve All the Sudoku, Leave No Joy for Solving by Yourself

Project description

Solve all the sudoku, leave no joy for solving by yourself

Why struggle for hours when you can solve any Sudoku in milliseconds? Just paste it in, hit Solve, and get on with your life. Your addiction ends here — and it feels great.

If you have a friend addicted to Sudoku, share this with them! ;)

Setup

Requirements: Python 3.9+

# Install from PyPI
pip install anti-sudoku

# Or install from source
git clone https://github.com/yuhhong/Anti-addiction_Sudoku.git
cd Anti-addiction_Sudoku
pip install .

Web UI

The web UI lets you generate puzzles or type one in manually, then solve it — or get step-by-step hints.

anti-sudoku serve

Opens http://localhost:8000 in your browser automatically. Both the page and the API are served together.

Features

  • Generate mode — pick a difficulty (Easy / Hard / Master / Grandmaster) and click Generate to load a fresh puzzle
  • Manual Input mode — click any cell and type a digit to enter your own puzzle
  • Solve — fills the entire board instantly
  • Hint — fills one cell and tells you which technique was used (e.g. "Row 4, Col 7 = 3 — X-Wing")
  • Clear — resets the board

CLI

# Solve a puzzle file
anti-sudoku solve anti_sudoku/puzzles/hard_001.txt

# Solve from a string (dots = blank cells)
anti-sudoku solve --input "53..7...."

# Generate a puzzle and print it
anti-sudoku generate --difficulty grandmaster

# Reproducible generation with a seed
anti-sudoku generate --difficulty hard --seed 42

# Start the web UI
anti-sudoku serve
anti-sudoku serve --host 0.0.0.0 --port 9000 --no-browser

Difficulty levels: easy · hard · master · grandmaster

Python Package

from anti_sudoku import solve, hint, generate

# Generate a puzzle (returns 81-char string, dots = blank)
puzzle = generate(difficulty="hard")
puzzle = generate(difficulty="grandmaster", seed=42)  # reproducible

# Solve a puzzle
solution = solve(puzzle)           # pass the string back in
solution = solve([0,5,3,0,...])    # or a list of 81 ints (0 = blank)
# Returns same type as input, or None if unsolvable

# Get one hint at a time
h = hint(puzzle)
# {"row": 3, "col": 6, "value": 7, "technique": "Hidden Single"}

Supported input formats

Format Example
81-char string "53..7.486..." — digits 1-9, dots for blank
list of 81 ints [5,3,0,0,7,0,4,8,6,...] — 0 for blank

Hint techniques

The hint function uses the simplest technique that currently applies:

Technique Description
Naked Single Only one candidate remains in a cell
Hidden Single A digit has only one valid position in a group
Naked Pairs/Triples N cells share exactly N candidates — eliminate from rest of group
Hidden Pairs/Triples N digits confined to N cells — eliminate other candidates from those cells
Pointing Pairs Digit in a block confined to one row/col — eliminate outside the block
X-Wing Digit in 2 rows shares the same 2 columns — eliminate from those columns
Swordfish X-Wing extended to 3 rows/columns
Backtracking Used only when no deterministic technique applies

Puzzle files

Built-in puzzles are in anti_sudoku/puzzles/. Format: space-separated digits, - for blank cells.

- 1 4 - 9 - - 7 -
8 - - 4 - - - 6 3
...

Reference

@inproceedings{simonis2005sudoku,
  title={Sudoku as a constraint problem},
  author={Simonis, Helmut},
  booktitle={CP Workshop on modeling and reformulating Constraint Satisfaction Problems},
  volume={12},
  pages={13--27},
  year={2005},
  organization={Citeseer}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anti_sudoku-0.1.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anti_sudoku-0.1.0-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file anti_sudoku-0.1.0.tar.gz.

File metadata

  • Download URL: anti_sudoku-0.1.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for anti_sudoku-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3349765fbc8dde2c776a59ca1ad88b2364d268118a9d4c0b5f6a8a625947326b
MD5 3e33dde65ca7d8943d9b3b68c3f5908b
BLAKE2b-256 ce48666449022adfd83f71a0898b4dd525716eb92a40d87f0b9f0394d4c2e00c

See more details on using hashes here.

File details

Details for the file anti_sudoku-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: anti_sudoku-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for anti_sudoku-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d6af4f56ae317c31e716402b71c08daedb7bc6f98e95bc65151a66c2228bf67
MD5 87e75f0332219110f2189041146ff8c1
BLAKE2b-256 560adac9e573ff48636efecf307550f06013e856285fc7a6c58fd315f2dc03c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page