Skip to main content

Convert Advent of Code ASCII art

Project description

Advent of Code® OCR

This Python module helps with converting Advent of Code ASCII art letters into plain characters. At the moment, it only 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 (2018 Day 10) is coming soon.

Put simply, it converts this to ABC:

 ██  ███   ██
█  █ █  █ █  █
█  █ ███  █
████ █  █ █
█  █ █  █ █  █
█  █ ███   ██

Installation

This module can be installed from PyPI:

$ pip install advent-of-code-ocr

Usage

Using this module is pretty easy. 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

advent-of-code-ocr-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

advent_of_code_ocr-1.0.0-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file advent-of-code-ocr-1.0.0.tar.gz.

File metadata

  • Download URL: advent-of-code-ocr-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for advent-of-code-ocr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b2f5593967eca658534cb23044b28a3e623de8a4df4c97e805bd50c5d741cd6c
MD5 6260e4a9ca8488313aa61758a51a62c8
BLAKE2b-256 2dc151f6aef000440b994dbab5357b44ff95a4ac7b01a9788341b1535990cefb

See more details on using hashes here.

File details

Details for the file advent_of_code_ocr-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for advent_of_code_ocr-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 690bcdad71e4246264ba1a4678e3666732bf1aa7b1bc285ab6b88bea263d5c40
MD5 85b588a733003599e2bc9fb9c0ad2d79
BLAKE2b-256 9f8c314bc1d4b4e54526290e454604fbe66d451476b687e0c808d638dfe16602

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