Skip to content

Commit 191e066

Browse files
Merge pull request #40 from SaridakisStamatisChristos/codex/set-up-mkdocs-with-github-pages
Add MkDocs documentation site and workflows
2 parents 0858e9e + 663fa34 commit 191e066

File tree

12 files changed

+336
-1
lines changed

12 files changed

+336
-1
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626
env:
2727
HYPOTHESIS_PROFILE: ci
2828
run: pytest -q --maxfail=1 --disable-warnings --cov=sudoku_dlx --cov-report=xml -m "not prop"
29+
- name: Build docs (no deploy)
30+
run: |
31+
python -m pip install -U mkdocs mkdocs-material
32+
mkdocs build --strict
2933
- name: Upload coverage to Codecov
3034
uses: codecov/codecov-action@v4
3135
with:

.github/workflows/docs.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: docs
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch: {}
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
- name: Install docs deps
20+
run: |
21+
python -m pip install -U pip
22+
python -m pip install -e ".[dev]"
23+
- name: Build docs
24+
run: mkdocs build --strict
25+
- name: Deploy to gh-pages/docs/
26+
uses: peaceiris/actions-gh-pages@v3
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./site
30+
destination_dir: docs
31+
keep_files: true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Fast **Sudoku** solver & generator using **Algorithm X / Dancing Links (DLX)** w
55
> © 2025 Stamatis-Christos Saridakis — MIT. Core algorithm: exact cover (Knuth). This implementation is original and bitset-based.
66
77
[![CI](https://github.com/SaridakisStamatisChristos/sudoku_dlx/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/SaridakisStamatisChristos/sudoku_dlx/actions/workflows/ci.yml)
8+
[![Docs](https://img.shields.io/badge/docs-mkdocs--material-blue)](https://SaridakisStamatisChristos.github.io/sudoku_dlx/docs/)
89
[![Codecov](https://codecov.io/gh/SaridakisStamatisChristos/sudoku_dlx/branch/main/graph/badge.svg)](https://codecov.io/gh/SaridakisStamatisChristos/sudoku_dlx)
910
[![License: MIT](https://img.shields.io/github/license/SaridakisStamatisChristos/sudoku_dlx.svg)](LICENSE)
1011
[![PyPI version](https://img.shields.io/pypi/v/sudoku_dlx.svg)](https://pypi.org/project/sudoku_dlx/)

docs/api.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Python API
2+
3+
```python
4+
from sudoku_dlx import (
5+
from_string, to_string, is_valid, solve, analyze, rate,
6+
count_solutions, generate, canonical_form, explain,
7+
build_reveal_trace, sat_solve
8+
)
9+
```
10+
11+
## Parsing
12+
```python
13+
g = from_string("53..7....6..195... ...") # 81 chars; .,0,-,_ are blanks
14+
s = to_string(g) # always 81 chars with dots for blanks
15+
```
16+
17+
## Solve
18+
```python
19+
res = solve(g) # None if unsolvable/invalid
20+
res.grid # 9x9 list of ints
21+
res.stats.ms, res.stats.nodes, res.stats.backtracks
22+
```
23+
24+
## Analyze
25+
```python
26+
analyze(g) # dict: {valid, solvable, unique, givens, difficulty, stats{...}}
27+
```
28+
29+
## Generate
30+
```python
31+
p = generate(seed=123, target_givens=30, minimal=True, symmetry="mix")
32+
```
33+
34+
## Canonical form
35+
```python
36+
can = canonical_form(g) # 81-char canonical string (isomorphism-invariant)
37+
```
38+
39+
## Difficulty
40+
```python
41+
score = rate(g) # [0, 10], deterministic (nodes/backtracks/gaps/fill)
42+
```
43+
44+
## Explain (human steps)
45+
```python
46+
exp = explain(g, max_steps=200)
47+
exp["steps"] # list of {type, strategy, ...}
48+
exp["progress"] # 81-char after steps
49+
exp["solution"] # full solution string (if solvable)
50+
```
51+
52+
## Trace (solution reveal)
53+
```python
54+
trace = build_reveal_trace(g, res.grid, res.stats)
55+
# keys: version, kind, initial, solution, steps, stats
56+
```
57+
58+
## SAT cross-check (optional)
59+
```python
60+
sat = sat_solve(g) # requires python-sat; returns 9x9 grid or None
61+
```

docs/batch.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Batch & Datasets
2+
3+
## Generate many puzzles
4+
```bash
5+
sudoku-dlx gen-batch --out puzzles.txt --count 1000 --givens 30 \
6+
--min-givens 28 --max-givens 40 --parallel 8
7+
```
8+
Puzzles are written one per line in **canonical** form, de-duplicated.
9+
10+
## Rate a file
11+
```bash
12+
sudoku-dlx rate-file --in puzzles.txt --json > scores.ndjson
13+
```
14+
15+
## Stats with sampling
16+
```bash
17+
sudoku-dlx stats-file --in puzzles.txt --limit 5000 --sample 1000 --json stats.json
18+
```
19+
20+
## Dedupe a file
21+
```bash
22+
sudoku-dlx dedupe --in puzzles.txt --out unique.txt
23+
```

docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog (highlights)
2+
3+
## 0.1.0
4+
- Bitset DLX solver with stats
5+
- Unique/minimal generator (symmetry options)
6+
- Canonicalization & dedupe
7+
- Difficulty v2 (deterministic)
8+
- Explain with human strategies (singles, pairs, triples, X-Wing, Swordfish, Simple Coloring)
9+
- Batch tools (`gen-batch`, `rate-file`, `stats-file`, `dedupe`)
10+
- Trace export + visualizer (`web/visualizer.html`)

docs/cli.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# CLI Guide
2+
3+
Run `sudoku-dlx --help` for a full list.
4+
5+
## Solve
6+
```bash
7+
sudoku-dlx solve --grid "<81chars>" [--pretty] [--stats] [--trace out.json] [--crosscheck sat]
8+
```
9+
10+
## Generate
11+
```bash
12+
sudoku-dlx gen --seed 123 --givens 30 [--minimal] [--symmetry none|rot180|mix] [--pretty]
13+
```
14+
15+
## Rate
16+
```bash
17+
sudoku-dlx rate --grid "<81chars>"
18+
```
19+
20+
## Check (analyze)
21+
```bash
22+
sudoku-dlx check --grid "<81chars>" [--json]
23+
```
24+
25+
## Canonicalize
26+
```bash
27+
sudoku-dlx canon --grid "<81chars>"
28+
```
29+
30+
## Explain (human steps)
31+
```bash
32+
sudoku-dlx explain --grid "<81chars>" [--json] [--max-steps 200]
33+
```
34+
35+
## Batch tools
36+
```bash
37+
# Generate unique canonical puzzles
38+
sudoku-dlx gen-batch --out puzzles.txt --count 1000 --givens 30 \
39+
--min-givens 28 --max-givens 40 --parallel 8
40+
41+
# Rate file (JSON lines)
42+
sudoku-dlx rate-file --in puzzles.txt --json > scores.ndjson
43+
44+
# Stats with sampling & histogram CSV
45+
sudoku-dlx stats-file --in puzzles.txt --limit 5000 --sample 1000 --json stats.json
46+
```

docs/index.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Sudoku DLX
2+
3+
Fast **Sudoku** solver & generator using **Algorithm X / Dancing Links** with **Python bitsets**.
4+
Includes **unique/minimal** generation, **difficulty v2**, **canonicalization**, **explainable steps**, batch tools, and a JS demo.
5+
6+
**Repo:** [:octicons-mark-github-16: GitHub](https://github.com/SaridakisStamatisChristos/sudoku_dlx) · **Docs:** this site · **Demo:** GitHub Pages `web/` and `visualizer.html`.
7+
8+
## Features
9+
- Bitset DLX solver with stats (nodes, backtracks)
10+
- Unique/minimal generator with symmetry controls
11+
- Deterministic **difficulty v2** ([0,10])
12+
- Canonical form & dataset de-duplication
13+
- Human strategies: singles, pairs, triples, **X-Wing**, **Swordfish**, **Simple Coloring**
14+
- CLI for solve/rate/gen/canon/explain/batch
15+
16+
## Install
17+
```bash
18+
python -m pip install sudoku_dlx # (after PyPI publish)
19+
```
20+
For development:
21+
```bash
22+
git clone https://github.com/SaridakisStamatisChristos/sudoku_dlx
23+
cd sudoku_dlx
24+
python -m venv .venv && source .venv/bin/activate
25+
pip install -e ".[dev]"
26+
```
27+
Optional SAT cross-check:
28+
```bash
29+
pip install -e ".[sat]"
30+
```
31+
32+
## Hello Sudoku
33+
```python
34+
from sudoku_dlx import from_string, solve, to_string, explain
35+
g = from_string("53..7....6..195... ...") # 81 chars; dots for blanks
36+
res = solve(g)
37+
print(to_string(res.grid))
38+
steps = explain(g, max_steps=200)
39+
print(steps["steps"][:3]) # preview moves
40+
```
41+
42+
## Links
43+
- CLI Guide: [CLI reference](cli.md)
44+
- API Reference: [Python API](api.md)
45+
- Strategies: [Human strategies](strategies.md)
46+
- Batch: [Datasets & tooling](batch.md)

docs/quickstart.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Quickstart
2+
3+
## Solve a puzzle
4+
```bash
5+
sudoku-dlx solve --grid "<81chars>" --pretty --stats
6+
```
7+
8+
## Generate
9+
```bash
10+
sudoku-dlx gen --seed 123 --givens 30 --pretty
11+
sudoku-dlx gen --seed 123 --givens 28 --minimal --symmetry rot180
12+
```
13+
14+
## Rate
15+
```bash
16+
sudoku-dlx rate --grid "<81chars>"
17+
```
18+
19+
## Analyze (valid/unique/difficulty)
20+
```bash
21+
sudoku-dlx check --grid "<81chars>" --json
22+
```
23+
24+
## Explain steps
25+
```bash
26+
sudoku-dlx explain --grid "<81chars>" --json --max-steps 200
27+
```
28+
29+
## Batch generate & stats
30+
```bash
31+
sudoku-dlx gen-batch --out puzzles.txt --count 1000 --givens 30 --parallel 8
32+
sudoku-dlx stats-file --in puzzles.txt --limit 5000 --sample 1000 --json stats.json
33+
```
34+
35+
## Trace & visualization
36+
```bash
37+
sudoku-dlx solve --grid "<81chars>" --trace out.json
38+
# Open web/visualizer.html and load out.json
39+
```

docs/strategies.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Human Strategies
2+
3+
Deterministic ordering, **one elimination per step** for stable playback:
4+
5+
## Placements
6+
- **Naked single** — only one candidate in a cell
7+
- **Hidden single** — the only place for a digit in a unit (row/col/box)
8+
9+
## Eliminations
10+
- **Locked candidates**
11+
- Pointing (box → line)
12+
- Claiming (line → box)
13+
- **Pairs**
14+
- Naked pair
15+
- Hidden pair
16+
- **Triples**
17+
- Naked triple
18+
- Hidden triple
19+
- **Fish**
20+
- X-Wing (rows/cols)
21+
- Swordfish (rows/cols)
22+
- **Coloring**
23+
- Simple coloring (Rule 2)
24+
25+
These are implemented in `sudoku_dlx/strategies.py` and consumed by `explain()`.

0 commit comments

Comments
 (0)