sudoku-solver

Sudoku solver - inspired by Tech With Tim.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      sudoku-solver:
        github: henrikac/sudoku-solver
  2. Run shards install

Usage

require "sudoku-solver"

input = [
  [5, 3, 0, 0, 7, 0, 0, 0, 0],
  [6, 0, 0, 1, 9, 5, 0, 0, 0],
  [0, 9, 8, 0, 0, 0, 0, 6, 0],
  [8, 0, 0, 0, 6, 0, 0, 0, 3],
  [4, 0, 0, 8, 0, 3, 0, 0, 1],
  [7, 0, 0, 0, 2, 0, 0, 0, 6],
  [0, 6, 0, 0, 0, 0, 2, 8, 0],
  [0, 0, 0, 4, 1, 9, 0, 0, 5],
  [0, 0, 0, 0, 8, 0, 0, 7, 9]
]
board = Sudoku::Board.new(input)

if Sudoku::Solver.solve(board) # solves in place
  puts "solved!"
else
  puts "not solved!"
end

Exceptions

Contributing

  1. Fork it (https://github.com/henrikac/sudoku-solver/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors