Nonogram Analysis
A nonogram is a puzzle game in which cells in a grid must be colored or left blank according to numbers at the side of the grid to reveal a hidden picture.
Nonogram Analysis is a Python library used to score a player who has completed a nonogram.
Nonogram Clues
The clues of a nonogram indicate for each column and each row of the nonogram the length of groups of marks of a column, respectively of a row, separated with one or more blanks.
For example:
║ | 1 | | 3 | 1 | | | 2 ║
║ 6 | 3 | 6 | 1 | 1 | 1 | 3 | 2 ║
║ 1 | 1 | 1 | 2 | 1 | 6 | 1 | 1 ║
========+===+===+===+===+===+===+===+===+
6 ║ X | X | X | X | X | X | | ║
--------+---+---+---+---+---+---+---+---+
1 2 1 ║ X | | X | X | | | | X ║
--------+---+---+---+---+---+---+---+---+
8 ║ X | X | X | X | X | X | X | X ║
--------+---+---+---+---+---+---+---+---+
3 2 ║ X | X | X | | | X | X | ║
--------+---+---+---+---+---+---+---+---+
8 ║ X | X | X | X | X | X | X | X ║
--------+---+---+---+---+---+---+---+---+
1 1 1 1 ║ X | | X | | | X | | X ║
--------+---+---+---+---+---+---+---+---+
1 2 ║ | | | X | | X | X | ║
--------+---+---+---+---+---+---+---+---+
4 1 1 ║ X | X | X | X | | X | | X ║
========+===+===+===+===+===+===+===+===+
We define the following language, using Backus–Naur Form (BNF), to declare the clues of a nonogram:
column_clues ::= integer "-" column_clues | integer
columns_clues ::= column_clues "," columns_clues | column_clues
row_clues ::= integer "-" row_clues | integer
rows_clues ::= row_clues "," rows_clues | row_clues
clues :== columns_clues "|" rows_clues
The clues of the nonogram above are:
6-1,1-3-1,6-1,3-1-2,1-1-1,1-6,3-1,2-2-1|6,1-2-1,8,3-2,8,1-1-1-1,1-2,4-1-1
Nonogram Analysis supports the class NonogramClues to build the clues of a nonogram.
For example:
>>> from nonogram.analysis import NonogramClues
>>> nonogram_clues = NonogramClues.from_string('1-1,1-1,2|2,1,3')
Nonogram Actions
We define the following Backus–Naur Form (BNF) to describe the syntax of a player's action performed on the cell of a nonogram:
action ::= action_type "-" cell_x "-" cell_y "-" action_time
action_time ::= integer
action_type ::= "F" | "M" | "C"
cell_x ::= integer
cell_y ::= integer
The term cell_x and cell_y represent the location of a cell in the nonogram's matrix. The origin (0, 0) of the nonogram is located at the topmost leftmost of the matrix.
The term action_time represents a variant of the UNIX timestamp, that is the number of milliseconds that have elapsed since the Unix epoch (00:00:00 UTC on 1 January 1970), minus leap seconds.
The term action_type represents the different possible action of a player:
F: Fill the cellM: Mark the cell to indicate it is emptyC: Clear the cell
For example:
F-5-3-1586485456389
Represents the action of filling the cell (5, 3) of a nonogram, performed by a player on Friday, April 10, 2020 at 02:24:16.389 AM:
║ | | | | | | |
==+===+===+===+===+===+===+===+...
║ | | | | | | |
--+---+---+---+---+---+---+---+...
║ | | | | | | |
--+---+---+---+---+---+---+---+...
║ | | | | | | |
--+---+---+---+---+---+---+---+...
║ | | | | | X | |
--+---+---+---+---+---+---+---+...
: : : : : : : :
. . . . . . . .
Nonogram Analysis supports the class NonogramClues to build the actions performed by a player on a nonogram.
For example:
>>> from nonogram.analysis import NonogramAction
>>> nonogram_actions = NonogramAction.from_strings('F-0-0-1593160278088,F-0-1-1593160279070,M-0-1-1593160279246,F-0-2-1593160281156,F-1-2-1593160281839,F-2-2-1593160282492,F-1-0-1593160284516,F-1-1-1593160285415,M-1-1-1593160285586,F-2-1-1593160288354')
Nonogram Game Session
Nonogram Analysis supports the class NonogramSession to build the game session of a player who attempted to solve a nonogram. The constructor of this class accepts the following arguments:
user: An objectUserrepresenting the player who played a nonogram.start_time: The objectdatetime.datetimethat represents the time when the nonogram game session started.clues: The list of objectsNonogramCluescorresponding to the clues of the nonogram that was given to the player to solve.actions: The list of objectsNonogramActionsthat represent the actions the player performed.
For example:
>>> import datetime
>>> from nonogram.analysis import NonogramSession
>>> nonogram_session = NonogramSession(
>>> ... None,
>>> ... datetime.datetime(2020, 6, 26, 8, 31, 14, 729000, tzinfo=datetime.timezone.utc),
>>> ... nonogram_clues,
>>> ... nonogram_actions)
>>> print(str(nonogram_session))
XX.
..X
XXX
>>> nonogram_session.is_solved
True
>>> calculate_nonogram_score(nonogram_session)
>>> 0.5152905198776758
Metadata
Release files for nonogram-analysis 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonogram-analysis-1.0.1.tar.gz | 13.7 kB | Without provenance | Details for nonogram-analysis-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonogram_analysis-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for nonogram_analysis-1.0.1-py3-none-any.whl |
Total release size: 25.7 kB
Release files / nonogram-analysis-1.0.1.tar.gz
| Download URL | nonogram-analysis-1.0.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c4dee5a12e7c2711d78fb6f3084cf4f4b8b860cf403fd59f4b6b52f2ddce5f1
|
|
BLAKE2b-256 checksum How to use checksums |
7c377b07809c0406dea9b9fe355a13daa453c15ea891cbcb97dfe4c14376ed6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3
|
Release files / nonogram_analysis-1.0.1-py3-none-any.whl
| Download URL | nonogram_analysis-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
013aeafb685197dcb684759ab1d6f6460a1ae53dcf9542314d18dcb34df2099f
|
|
BLAKE2b-256 checksum How to use checksums |
70c9971f0e21e78c77571ff9e2bc8b7d1b38aeb0a56a2245c603e3f00b2b8489
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3
|
Security for nonogram-analysis 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.