advent-of-code-ocr

Crates.ioadvent-of-code-ocr
lib.rsadvent-of-code-ocr
version0.1.1
sourcesrc
created_at2022-12-10 13:35:17.745707
updated_at2022-12-10 13:52:23.793338
descriptionSmall crate to help convert AoC text screens to strings
homepage
repositoryhttps://github.com/OliverFlecke/advent-of-code-rust/tree/main/advent-of-code-ocr
max_upload_size
id733839
size9,132
Oliver (OliverFlecke)

documentation

README

OCR for Advent of Code puzzles

Crate to convert Advent of Code from ASCII letters to characters. This is required for several of the puzzle days through the years, including: 2016/09, 2019/08, 2019/11, 2021/13, and 2022/10.

This has been made to help automate parsing of those puzzles for my own AoC solutions, but are shared for others interest.

Installation

cargo install advent-of-code-ocr

Usage

The main function to parse a screen from AoC is the parse_string_to_letters.

use advent_of_code_ocr::parse_string_to_letters;

// Input is:
// ####.###....##.###..###..#..#..##..#..#.
// #....#..#....#.#..#.#..#.#.#..#..#.#..#.
// ###..#..#....#.###..#..#.##...#..#.####.
// #....###.....#.#..#.###..#.#..####.#..#.
// #....#....#..#.#..#.#.#..#.#..#..#.#..#.
// ####.#.....##..###..#..#.#..#.#..#.#..#.
let input = "####.###....##.###..###..#..#..##..#..#.\n#....#..#....#.#..#.#..#.#.#..#..#.#..#.\n###..#..#....#.###..#..#.##...#..#.####.\n#....###.....#.#..#.###..#.#..####.#..#.\n#....#....#..#.#..#.#.#..#.#..#..#.#..#.\n####.#.....##..###..#..#.#..#.#..#.#..#.";

assert_eq!(parse_string_to_letters(input), "EPJBRKAH");

Two other functions are exposed by this crate:

  • parse_letter which tries to convert a single AoC character to a Option<char>
  • split_screen which splits a full AoC screen to individual AoC characters.
Commit count: 0

cargo fmt