A library to parse Advent of Code ASCII art
Project description
Advent of Code® OCR
This Python module converts Advent of Code ASCII art letters to plain characters.
At the moment, it supports 6-pixel-tall characters as seen in 2016 Day 8, 2019 Days 8 and 11, and 2021 Day 13. (Support for 10-pixel-tall characters, as seen in 2018 Day 10, is coming soon.)
Put simply, it converts something like this to plain text:
██ ███ ██
█ █ █ █ █ █
█ █ ███ █
████ █ █ █
█ █ █ █ █ █
█ █ ███ ██
Installation
Advent of Code OCR is available on PyPI:
$ pip install advent-of-code-ocr
Advent of Code OCR officially supports Python 3.7+.
API Reference
By default, this module recognizes # as a filled pixel and . as an empty
pixel. However, you can change this using the fill_pixel and empty_pixel
keywork arguments respectively.
from advent_of_code_ocr import convert_6
print(convert_6(".##.\n#..#\n#..#\n####\n#..#\n#..#"))
# A
print(convert_6(" $$ \n$ $\n$ $\n$$$$\n$ $\n$ $", fill_pixel="$", empty_pixel=" "))
# A
You can also convert data that you have in a NumPy array or a nested list:
from advent_of_code_ocr import convert_array_6
array = [
[0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0],
[1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1],
[1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0],
[1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0],
[1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1],
[1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0],
]
print(convert_array_6(array, fill_pixel=1, empty_pixel=0))
# AOC
Advent of Code is a registered trademark of Eric K Wastl in the United States.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file advent_of_code_ocr-1.1.0.tar.gz.
File metadata
- Download URL: advent_of_code_ocr-1.1.0.tar.gz
- Upload date:
- Size: 59.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f03373e2d364b30da9a168064ed9342c6e18b7a443f433e551038e8437671ba7
|
|
| MD5 |
df9808c23b1f5dd301ebd360ac283892
|
|
| BLAKE2b-256 |
a49cd0c55e029ade2854def3af78a896e012b4c57d7ef089782f63d34cd6466a
|
Provenance
The following attestation bundles were made for advent_of_code_ocr-1.1.0.tar.gz:
Publisher:
publish.yml on bsoyka/advent-of-code-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
advent_of_code_ocr-1.1.0.tar.gz -
Subject digest:
f03373e2d364b30da9a168064ed9342c6e18b7a443f433e551038e8437671ba7 - Sigstore transparency entry: 312619281
- Sigstore integration time:
-
Permalink:
bsoyka/advent-of-code-ocr@d70f5953770d0351738ade95a42c4903b0204447 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/bsoyka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d70f5953770d0351738ade95a42c4903b0204447 -
Trigger Event:
release
-
Statement type:
File details
Details for the file advent_of_code_ocr-1.1.0-py3-none-any.whl.
File metadata
- Download URL: advent_of_code_ocr-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5a0668b88e94a8d7319fe024a8840799bf1ba8526fc4a5b5f5178459d678a36
|
|
| MD5 |
f3e6b9df55e3fedc6e3a3cc7a436e158
|
|
| BLAKE2b-256 |
3ddbeff655bb8654353ad2821a77608c5335769673e22c0f3868c503bd705a03
|
Provenance
The following attestation bundles were made for advent_of_code_ocr-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on bsoyka/advent-of-code-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
advent_of_code_ocr-1.1.0-py3-none-any.whl -
Subject digest:
a5a0668b88e94a8d7319fe024a8840799bf1ba8526fc4a5b5f5178459d678a36 - Sigstore transparency entry: 312619310
- Sigstore integration time:
-
Permalink:
bsoyka/advent-of-code-ocr@d70f5953770d0351738ade95a42c4903b0204447 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/bsoyka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d70f5953770d0351738ade95a42c4903b0204447 -
Trigger Event:
release
-
Statement type: