Xudoku

Sudoku puzzle generator and solver with a very simple, clean interface.

The solver and generator is inspired David Bau's version. https://davidbau.com/downloads/sudoku.py

Installation

$ gem install xudoku

Usage

To use Xudoku

require "xudoku"

Generate a puzzle and solution pair

puzzle = Xudoku.generate

# Puzzle
puzzle_board = puzzle.puzzle

# Solution
solution_board = puzzle.solution

Both puzzle and solution are an instance of Xudoku::Board. You can export the board to different formats

# String
board.to_s

# Array rows x cols
board.to_a

# JSON. Same as array
board.to_json

Solve sudoku puzzles

# Returns a puzzle and solution pair, just like generate
puzzle = Xudoku.solve(puzzle_string)

# Using a file input
puzzle = Xudoku.solve(File.open('/path/to/puzzle'))

# Using a flatted 81 item array. Ex: [9, 8, 1 ... 7, 2, 6]
# Or using a [9][9] array: Ex: [[9, 8, 1, 3, 2, 4, 5, 6, 7] ... [8, 3, 9, 1, 4, 5, 7, 2, 6]]
puzzle = Xudoku.solve(array)

Authors

Created and maintained by

Venkatakrishnan Ganesh

License

Xudoku is licensed under the MIT license.

See LICENSE for the full license text.