#puzzle-solver #nonogram #color #color-space #solution #solving #color-type

bin+lib nonogram-rs

A fast and lightweight nonogram solving library

9 stable releases

2.2.3 Jan 4, 2023
2.2.1 Jan 3, 2023
2.2.0 Dec 31, 2022
2.0.0 May 21, 2022
1.0.1 Jan 6, 2022

#3 in #puzzle-solver

Download history 109/week @ 2024-02-13 15/week @ 2024-02-20 14/week @ 2024-02-27

138 downloads per month

GPL-3.0-or-later

70KB
2K SLoC

nonogram-rs

A fast and lightweight nonogram solving library.

Features:

  • Solving regular puzzles
  • Solving colored puzzles (with arbitrary color type)
  • Finding all solutions to a puzzle
  • Multithreading using rayon
  • De/serializing using serde (requires serde feature)

Examples of how to use this library can be found in the tests/ directory.

Command-line interface

This library includes a CLI called nonogram-cli as a binary target.

cargo build --bin nonogram-cli --features='cli'
# Solve
cat layout.json | ./nonogram-cli solve > result.json

# Show
cat result.json | ./nonogram-cli show

# Both in one line
cat layout.json | ./nonogram-cli solve | ./nonogram-cli show

Example layout

{
  "cols": [
    [["y", 1], ["y", 1]],
    [["r", 3]],
    [["r", 1]]
  ],
  "rows": [
    [["y", 1], ["r", 1]],
    [["r", 1]],
    [["y", 1], ["r", 2]]
  ]
}

Example result

[
  [
    [{"Box":{"color":"y"}}, {"Box":{"color":"r"}}, "Space"],
    ["Space",               {"Box":{"color":"r"}}, "Space"],
    [{"Box":{"color":"y"}}, {"Box":{"color":"r"}}, {"Box":{"color":"r"}}]
  ]
]

Result

Colors

The following colors are supported by the CLI. Lowercase letters are dark and uppercase letters are bright colors. Note that the library supports arbitrary color types.

Key Color Key Color Key Color
! default R red r dark red
0 black G green g dark green
1 dark grey Y yellow y dark yellow
2 grey B blue b dark blue
3 white M magenta m dark magenta
C cyan c dark cyan

Algorithm

The algorithm is explained in detail in a separate document.

License

This software (including the complete source code) is licensed under the GPLv3.

Dependencies

~1–11MB
~92K SLoC