/nonogram

Command-line Nonogram solver

Primary LanguageCGNU General Public License v2.0GPL-2.0

Purpose

This is a command-line utility for solving, generating and testing Nonograms.

Installation

Installation depends on Binodeps and Nonogram library.

To install in /usr/local:

make
sudo make install

Override the default location by setting PREFIX. This can be set on the command line:

make PREFIX=$HOME/.local install

…or in a local file config.mk:

PREFIX=$(HOME)/.local

…or in nonogram-env.mk, which is sought on GNU Make's search path, set by -I:

make -I$HOME/.config/local install

You probably want to set some more optimal compilation options, and find the Nonogram library, e.g., by placing them in config.mk:

CFLAGS += -O2 -g
PREFIX=$(HOME)/.local
CPPFLAGS += -I$(PREFIX)/include
LDFLAGS += -L$(PREFIX)/lib

Installation places installs the following files under $(PREFIX):

bin/nonogram

Formats

Puzzles the format defined by the Nonogram Library. Solutions are simple text files consisting of lines of # for foreground colour and - for background colour.

Use

The nonogram command processes switches and filenames in order. Some switches modify a context:

  • -is – Read from standard input (the default).
  • -i file – Read from file.
  • -os – Write to standard output (the default).
  • -o file – Write to file. Multiple solutions are separated by blank lines.
  • -on file-%d.txt – Write each solution to file-1.txt, file-2.txt, etc.
  • +o – Disable solution/puzzle output.
  • -v – Clear screen and display the grid as the solution is solved. The standard error output is used.
  • +v – Don't display the grid during solving.
  • -Afast – Use the fast algorithm.
  • -Acomplete – Use the slow exhaustive algorithm.
  • -Ahybrid – Use the fast algorithm first, then the slow exhaustive one.
  • -Afcomp – Use the fast comprehensive algorithm.
  • -Affcomp – Use the fast algorithm, then the fast comprehensive algorithm.
  • -Aolsak – Use the Olšáks' algorithm.
  • -Afastolsak – Use the fast algorithm, then the Olšáks'.
  • -Afastolsakcomplete – Use the fast algorithm, then the Olšáks', then the slow exhaustive.
  • -Afastodd – Probably the same as -Afastolsak, but odd was intended to diverge.
  • -Afastoddcomplete – Probably the same as -Afastolsakcomplete.
  • -CO, -CE – Display a count of solutions when complete, on standard output or standard error output respectively.
  • +CO, +CE – Disable count of solutions, on standard output or standard error output respectively.
  • -s num – Stop after n solutions. Use -n 2 to detect bad puzzles that have more than one solutions.
  • -log file.log – Append logging information to file.log.
  • -nlog file.log – Overwrite file.log with logging information.
  • +log, +nlog – Cancel logging (default).
  • -ll num – Set log detail to num (default 0).
  • -Dkey – Delete the metadata specified by key.
  • -Rkey value – Set or replace the metadata specified by key.
  • -Xkey – Print the metadata specified by key.
  • -W – Print the width.
  • -H – Print the height.

Other switches act on the current context before further argument processing:

  • -x – Load a puzzle from the source, and solve it, writing solutions to the destination. This switch is assumed at the end if the context has changed since the last action switch.
  • -p – Print the current context.
  • -c – Load a puzzle, and display the sum of row clues minus the sum of column clues.
  • -g – Load a grid from the source, stopping at end-of-file, or on first line with a different length, and write out a puzzle.

Examples

nonogram -on flower%d.txt -v -i flower.non -x

Solve flower.non, printing results in flower1.txt, flower2.txt, …, and display work.

nonogram -x < duck.non

Solve duck.non, print to stdout.

nonogram +o -v -x < duck.non

Show duck.non being solved. Don't produce solution.

cat duck.non flower.non | nonogram +o -v -x -x

Solve two puzzles from stdin. Display working but give no other output.