# advent-ocr A Rust function to convert ASCII-art representations of letters generated by Advent of Code puzzles into a String containing those letters. Through 2023, these puzzles are: * 2016, Day 8 * 2018, Day 10 * 2019, Days 8 and 11 * 2011, Day 13 * 2022, Day 10 ## Installation Add this to your Cargo.toml file: ```sh [dependencies] advent-ocr = "0.1.3" ``` ## Usage There is one function, `ocr()`, that takes one argument, `image`. `image` can take the following types: * `&str` * `(&Vec, usize)`, a tuple consisting of a Vec of bools and the width of a line. * `(&Vec, usize)`, a tuple consisting of a Vec of chars and the width of a line. * `&Vec>`, a Vec of a Vec of bools. * `&Vec>`, a Vec of a Vec of chars. For &str and the char-based Vecs, '#' is considered part of a letter and all other chars are considered blank space. For the bool-based Vecs, `true` is considered part of a letter and `false` is considered blank space. ```sh use advent_ocr::ocr let image = r" .##..###...##. #..#.#..#.#..# #..#.###..#... ####.#..#.#... #..#.#..#.#..# #..#.###...##. "; let s = ocr(image); println!("{s}"); // prints "ABC" ``` ## Warning/Credits This library recognizes the two font sizes used in Advent of Code puzzles, but neither font alphabet is complete. This draws on the efforts of [mstksg](https://github.com/mstksg) and possibly others. If the function does not recognize a letter, send me a message with the image that failed to render, and I will add it! ## License Licensed under either of - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option.