https://github.com/direvus/sudoku
A small sudoku library written in Go.
I wrote this library in order to learn the Go programming language. It is not intended to be useful, or expected to be novel.
The original inspiration for the library and the input format comes from Andrew Gerrand's November 2015 Go Challenge [http://golang-challenge.org/go-challenge8/], although this library is not written as a submission for that challenge.
- Install go v1.10.x
- Checkout the repository
- Execute
make build
- Copy the resulting binaries from
build/
to wherever you like - Use them!
The sudoku-solve
executable takes a sudoku puzzle on stdin, attempts to solve it,
and produces the result on stdout.
The input format is one line per row, each line terminated by a single newline character (0x0a). Cells within the row are delimited by a single space character (0x20). Unknown cells are indicated by the underscore character (0x5f).
So, for example:
_ _ 8 _ _ 6 2 5 _
_ _ _ _ 7 _ _ 3 _
_ _ _ _ 1 2 9 8 _
_ _ 5 _ _ 3 _ _ _
_ 2 _ 7 _ 1 _ 6 _
_ _ _ 8 _ _ 1 _ _
_ 3 6 2 8 _ _ _ _
_ 7 _ _ 9 _ _ _ _
_ 8 2 1 _ _ 4 _ _
The sudoku-gen
executable generates a random sudoku solution grid, and a
random selection of clues to offer, and produces the resulting puzzle on
stdout. The output format is identical to the input and output format of
sudoku-solve
.
The selection of clues is 'minimal', meaning that removing any of the clues would result in an improper puzzle (i.e., a puzzle with more than one possible solution).
This library is released under the terms of the BSD 2-clause license, a copy of which can be found in the file 'LICENSE' at the root directory of this repository.