Skip to main content

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

Release files for picross-solver 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for picross-solver 1.1.2
File Size Uploaded
picross-solver-1.1.2.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for picross-solver 1.1.2
File Interpreter ABI Platform
picross_solver-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / picross-solver-1.1.2.tar.gz

Download URL picross-solver-1.1.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a117873d5bf6d0eb821c299a4172ed9b261665086256002bdfaf9f551ab4305b
BLAKE2b-256 checksum
How to use checksums
26ec4850d1846b2913ead1b831fe7badf4c64c83d788f74705834039b6d32247
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / picross_solver-1.1.2-py3-none-any.whl

Download URL picross_solver-1.1.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a25fb2055a2c6d727d7408a153fe50645522d41b9b36bb24e0689fbf6b9ce96
BLAKE2b-256 checksum
How to use checksums
b641f202c134acc3f0fa03b96b9688ce63d6f7578a63546f9cdc98f7269403a4
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page