Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patryk27/nonogram-solver
Solves monochromatic nonograms, powered by Rust and Z3
https://github.com/patryk27/nonogram-solver
crossword nonogram nonograms puzzle rust sat z3
Last synced: 12 days ago
JSON representation
Solves monochromatic nonograms, powered by Rust and Z3
- Host: GitHub
- URL: https://github.com/patryk27/nonogram-solver
- Owner: Patryk27
- License: mit
- Created: 2024-03-30T19:06:25.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-30T19:15:58.000Z (8 months ago)
- Last Synced: 2024-10-10T20:11:09.067Z (about 1 month ago)
- Topics: crossword, nonogram, nonograms, puzzle, rust, sat, z3
- Language: Rust
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nonogram-solver
Solves monochromatic [nonograms](https://en.wikipedia.org/wiki/Nonogram),
powered Rust and Z3, pretty rudimentary.## Usage
(requires rustup and z3)
```
$ cargo run -- \
--cols '1|1|2|4|7|9|2,8|1,8|8|1,9|2,7|3,4|6,4|8,5|1,11|1,7|8|1,4,8|6,8|4,7|2,4|1,4|5|1,4|1,5|7|5|3|1|1' \
--rows '8,7,5,7|5,4,3,3|3,3,2,3|4,3,2,2|3,3,2,2|3,4,2,2|4,5,2|3,5,1|4,3,2|3,4,2|4,4,2|3,6,2|3,2,3,1|4,3,4,2|3,2,3,2|6,5|4,5|3,3|3,3|1,1'# https://en.wikipedia.org/wiki/Nonogram#/media/File:Nonogram_wiki.svg
``````
******** ******* ***** *******
***** **** *** ***
*** *** ** ***
**** *** ** **
*** *** ** **
*** **** ** **
**** ***** **
*** ***** *
**** *** **
*** **** **
**** **** **
*** ****** **
*** ** *** *
**** *** **** **
*** ** *** **
****** *****
**** *****
*** ***
*** ***
* *
```## Implementation
Nonogram can be represented as a set of regular expressions - e.g. column with
numbers `1` and `8` is:```
^[ ]*\*{1}[ ]+\*{8}[ ]*$
```... or, with a couple of comments:
```
^ [ ]* \*{1} [ ]+ \*{8} [ ]* $
1--- 2---- 3--- 4---- 5---1 - any number of leading spaces
2 - exactly one asterisk
3 - at least one separating space
4 - exactly eight asterisks
5 - any number of trailing spaces
```Following on this, nonogram-solver builds a regular expression for each column
and row, then sends those constraints to Z3 and parses its response back.## License
Copyright (c) 2024, Patryk Wychowaniec,
Licensed under the MIT license.