https://github.com/shuber/sudoku
Solves traditional square Sudoku puzzles
https://github.com/shuber/sudoku
Last synced: 10 months ago
JSON representation
Solves traditional square Sudoku puzzles
- Host: GitHub
- URL: https://github.com/shuber/sudoku
- Owner: shuber
- License: mit
- Created: 2009-10-12T00:33:04.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2009-10-12T23:35:51.000Z (over 16 years ago)
- Last Synced: 2025-02-25T21:42:23.618Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Awesome Lists containing this project
README
= sudoku
Solves traditional square Sudoku puzzles
See http://en.wikipedia.org/wiki/Sudoku
== Usage
board = [
[ 2, nil, nil, nil, nil, 1, nil, 3, 8],
[nil, nil, nil, nil, nil, nil, nil, nil, 5],
[nil, 7, nil, nil, nil, 6, nil, nil, nil],
[nil, nil, nil, nil, nil, nil, nil, 1, 3],
[nil, 9, 8, 1, nil, nil, 2, 5, 7],
[ 3, 1, nil, nil, nil, nil, 8, nil, nil],
[ 9, nil, nil, 8, nil, nil, nil, 2, nil],
[nil, 5, nil, nil, 6, 9, 7, 8, 4],
[ 4, nil, nil, 2, 5, nil, nil, nil, nil]
]
sudoku = Sudoku::Puzzle.new(board, :blank => '.')
puts sudoku.puzzle
# 2 . . . . 1 . 3 8
# . . . . . . . . 5
# . 7 . . . 6 . . .
# . . . . . . . 1 3
# . 9 8 1 . . 2 5 7
# 3 1 . . . . 8 . .
# 9 . . 8 . . . 2 .
# . 5 . . 6 9 7 8 4
# 4 . . 2 5 . . . .
puts sudoku.solve!.puzzle
# 2 4 9 5 7 1 6 3 8
# 8 6 1 4 3 2 9 7 5
# 5 7 3 9 8 6 1 4 2
# 7 2 5 6 9 8 4 1 3
# 6 9 8 1 4 3 2 5 7
# 3 1 4 7 2 5 8 6 9
# 9 3 7 8 1 4 5 2 6
# 1 5 2 3 6 9 7 8 4
# 4 8 6 2 5 7 3 9 1
== TODO
* Finish tests
* Look into failures with default solver
== Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but
bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.
== Copyright
Copyright (c) 2009 Sean Huber. See MIT-LICENSE for details.