~rkta/ksudbf

Killer sudoku brute forcer

ed6bf9e Iterate cages instead of cells

~rkta pushed to ~rkta/ksudbf git

1 year, 1 month ago

96595c4 Add pretty print command

~rkta pushed to ~rkta/ksudbf git

1 year, 1 month ago
ksudbf
======

A solver for killer sudokus using brute force.

ksudbf stands for killer sudoku brute forcer.  It was intentionally abbreviated
to six awkward letters.

ksudbf will try to solve a given killer sudoku using recursive backtracking.
It prints either a solution to stdout or exits with an error.


Usage
-----
ksudbf [FILE]

With no FILE, or when FILE is -, read standard input.


Input format
------------

The input file has the following format:
cage sum <space> coordinate <space> ... <newline>

Example:
A 'L'-shaped cage with hint/value 6 and 3 cells in the top left corner:
6 11 12 21

See example/ for a complete example including the solution.

The following table shows all coordinates:
|----------+----------+----------|
| 11 12 13 | 14 15 16 | 17 18 19 |
| 21 22 23 | 24 25 26 | 27 28 29 |
| 31 32 33 | 34 35 36 | 37 38 39 |
|----------+----------+----------|
| 41 42 43 | 44 45 46 | 47 48 49 |
| 51 52 53 | 54 55 56 | 57 58 59 |
| 61 62 63 | 64 65 66 | 67 68 69 |
|----------+----------+----------|
| 71 72 73 | 74 75 76 | 77 78 79 |
| 81 82 83 | 84 85 86 | 87 88 89 |
| 91 92 93 | 94 95 96 | 97 98 99 |
|----------+----------+----------|


Hints
=====

ksudhints lets you show the solution step by step. You can reveal specific
cells or get a hint for an unspecified cell. Cages with fewer cells are
revealed earlier, starting in the top left corner. It also let's you fill in
already solved cells while ignoring wrong input.


Usage
-----

ksudhints -s FILE -p FILE

-s	a solution as given by ksudbf
-p	the input file for the solution (same format as ksudbf)

With most recent shells one can use:
$ ksudhints -p FILE -s <(ksudbf <FILE)

Commands:
XY [r]     - Reveal cell XY.
[XY] r [N] - Reveal 1 or N random cells starting with cell XY.
XY t N     - Test if cell XY has value N
n [N]      - Show 1 or N next hints.
p          - Print the board.
P          - Pretty print the board.
s          - Show a table with all coordinates.
e          - Open the board in $EDITOR (to add values to the partial solution).
h          - Show this help text.

Press <Enter> without command to repeat the previous one.

Press ^D to see the complete solution and exit.


See my blog post[0] for a little tutorial.

[0]: https://rkta.de/ksudbf.html


Installation
============

See INSTALL