Skip to content

Add an example sudoku solver#220

Merged
baszalmstra merged 5 commits into
prefix-dev:mainfrom
benmoss:main
May 15, 2026
Merged

Add an example sudoku solver#220
baszalmstra merged 5 commits into
prefix-dev:mainfrom
benmoss:main

Conversation

@benmoss
Copy link
Copy Markdown
Contributor

@benmoss benmoss commented May 14, 2026

Just for fun, and to show that it's possible:

✦ ❯ cargo run --example sudoku -- "020016005000000400306000207600075040000000000080230006207000604005000000100590070"

┌───────┬───────┬───────┐
│ . 2 . │ . 1 6 │ . . 5 │
│ . . . │ . . . │ 4 . . │
│ 3 . 6 │ . . . │ 2 . 7 │
├───────┼───────┼───────┤
│ 6 . . │ . 7 5 │ . 4 . │
│ . . . │ . . . │ . . . │
│ . 8 . │ 2 3 . │ . . 6 │
├───────┼───────┼───────┤
│ 2 . 7 │ . . . │ 6 . 4 │
│ . . 5 │ . . . │ . . . │
│ 1 . . │ 5 9 . │ . 7 . │
└───────┴───────┴───────┘

┌───────┬───────┬───────┐
│ 4 2 9 │ 7 1 6 │ 3 8 5 │
│ 7 1 8 │ 3 5 2 │ 4 6 9 │
│ 3 5 6 │ 8 4 9 │ 2 1 7 │
├───────┼───────┼───────┤
│ 6 3 2 │ 9 7 5 │ 1 4 8 │
│ 9 7 1 │ 4 6 8 │ 5 2 3 │
│ 5 8 4 │ 2 3 1 │ 7 9 6 │
├───────┼───────┼───────┤
│ 2 9 7 │ 1 8 3 │ 6 5 4 │
│ 8 4 5 │ 6 2 7 │ 9 3 1 │
│ 1 6 3 │ 5 9 4 │ 8 7 2 │
└───────┴───────┴───────┘

There's tons of puzzles in this format in https://github.com/grantm/sudoku-exchange-puzzle-bank

benmoss and others added 5 commits May 14, 2026 15:57
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add module-level documentation with a concept mapping table, section
headers, and inline comments explaining key design decisions like
the complement-set constraint encoding and locked candidates.

Also print the unsolved puzzle before the solution, and display
empty cells as dots.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool! Thank you!

@baszalmstra baszalmstra merged commit 9e6a342 into prefix-dev:main May 15, 2026
9 checks passed
@ruben-arts
Copy link
Copy Markdown
Contributor

Haha so fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants