Skip to main content

A picross/nonogram solver.

Project description

Picross Solver

Build Status

A python program that solves black and white nonogram (aka Picross, Paint by Numbers, Griddlers, Pic-a-Pix, Hanjie, and Japanese Crosswords) puzzles.

Can solve medium to large puzzles within a second or less; solves small puzzles nearly instantly.

Installation

This program requires numpy and Python version 3.4 or higher to work correctly.

To install, simply run pip install picross-solver

Usage

Once the package is installed, import the package with from picross_solver import picross_solver. After that, you should have access to the solve() function.

The solve() function takes in 3 arguments -- an array of arrays for the row clues/constraints, an array of arrays for the col clues/constraints, and a 2d numpy array representing the puzzle grid. In the puzzle grid, values -1, 0, and 1 represent a cell that is unknown, empty, or full, respectively. solve() will attempt to fill in the provided puzzle variable, overwriting the puzzle grid in the process. solve() will return True if a solution has been found, and the provided puzzle grid will be overwritten with a solution to the puzzle; it will return False if it couldn't find a solution.

Example

Using py

>>> from picross_solver import picross_solver
>>> import numpy as np
>>> rows = [[1, 1], [0], [3]]
>>> cols = [[1, 1], [1], [1, 1]]
>>> puzz = np.full((3, 3), -1)
>>> print(puzz)
[[-1 -1 -1]
 [-1 -1 -1]
 [-1 -1 -1]]
>>> picross_solver.solve(rows, cols, puzz)
True
>>> print(puzz)
[[1 0 1]
 [0 0 0]
 [1 1 1]]

How it Works

This solver works by attempting to fill in a single line at a time, iterating over all of the lines and keeping track of which ones have been updated. If no progress has been made with the linesolver, the program makes a guess and recursively runs the solver.

More information about the line-solving algorithm can be found here: https://scc-forge.lancaster.ac.uk/open/nonogram/ls-fcomp

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picross-solver-1.1.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

picross_solver-1.1.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file picross-solver-1.1.2.tar.gz.

File metadata

  • Download URL: picross-solver-1.1.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.6

File hashes

Hashes for picross-solver-1.1.2.tar.gz
Algorithm Hash digest
SHA256 a117873d5bf6d0eb821c299a4172ed9b261665086256002bdfaf9f551ab4305b
MD5 e82cbdd19860e568864f2c81450e626d
BLAKE2b-256 26ec4850d1846b2913ead1b831fe7badf4c64c83d788f74705834039b6d32247

See more details on using hashes here.

File details

Details for the file picross_solver-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: picross_solver-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.6

File hashes

Hashes for picross_solver-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a25fb2055a2c6d727d7408a153fe50645522d41b9b36bb24e0689fbf6b9ce96
MD5 ced6a2f6ac3d1a6eb451aaaadd7a2243
BLAKE2b-256 b641f202c134acc3f0fa03b96b9688ce63d6f7578a63546f9cdc98f7269403a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page