My rust solutions to Advent of Code puzzles.
This project uses aoc-runner
and cargo-aoc
cargo-aoc does not support workspaces and multi-year projects, so you have to run them as binaries.
cargo build
cargo run --bin aoc2021
To run a release version add --release
to the above arguments
To run tests:
cargo test
cargo-aoc can be used to get your input data, you need to set your aoc web session id with
cargo aoc credentials -s {token} # get this from Application tab in chrome tools for aoc website
then you can just run
cargo aoc input [ -d {day} -y {year} ] # defaults to today's date
cargo aoc input -d 4 -y 2021
To parse the input quickly, use #[aoc_generator(dayX}]
and implement a function that will convert the
data input file to types required. e.g. for day 01, a list of strings that need to be converted to integers:
#[aoc_generator(day1)]
pub fn input_generator(input: &str) -> Vec<u32> {
common::input_vec(input)
}
Other examples are in the cargo_aoc docs and in the worked solutions, e.g. src/day_03.rs