Crates.io | aoc-next |
lib.rs | aoc-next |
version | 0.1.0 |
source | src |
created_at | 2020-12-02 17:08:54.100527 |
updated_at | 2020-12-02 17:08:54.100527 |
description | Helper library for Advent of Code. Inspired by cargo-aoc. |
homepage | |
repository | https://gitlab.com/liketechnik/aoc-next |
max_upload_size | |
id | 318955 |
size | 36,493 |
Helper library for Advent of Code, inspired by cargo-aoc
.
Include the crate as a library.
Then declare a static Aoc
struct to 'register' your solutions.
It will probably look similiar to this one:
const AOC: Aoc = Aoc {
allow_download: true,
year: 2020,
solutions: &[
solution!{1, failable_parser!{ day1::input_generator }, solver!{ day1::solve_part1 }},
solution!{1, failable_parser!{ day1::input_generator }, solver!{ day1::solve_part2 }},
solution!{2, failable_parser!{ day2::input_generator }, solver!{ day2::solve_part1 }},
solution!{2, failable_parser!{ day2::input_generator }, solver!{ day2::solve_part2 }},
],
};
To be able to run your solutions add app::aoc_main
to your main method.
It will take care of providing the input to your parsers and executing your solutions.
If you only want to see the solutions for a specific day, just pass the
number as the first argument: cargo run --release 2
to run all solutions for day 2, for example.
You will need to find your session token for the AoC in order for the automatic download to work. Thankfully, finding your token is easy since it is stored in your Browser's cookies. Open up the devtools of your browser, and then :
Now put them into .aoc_session.txt
next to your project's Cargo.toml
.
Important: Make sure to add .aoc_session.txt
to your .gitignore
, so you don't actually commit
your session token!
See https://github.com/liketechnik/aoc-2020 for example usage of the library or open an issue if you should have any problems. I'm also available on the rust discord(s) (as liketechnik#8562).