This is a template for easier implementations of Advent of Code in Rust.
Some of the features of thist template include:
- The
Solution
trait that abstracts some of the boilerplate for each task. - Utilities to automatically download the puzzle inputs.
- A copy and modify flow for quick day setup.
- Install Rust
- Clone this Repo
- (Optional) go to
src/aoc/data.rs
and change the year
I've used day_00 as a test day and show examples of how to use the flow.
cargo run --bin day_00 -- <options>
This command builds and runs day_00 on input dependent on <options>
.
When day_00 is ran the input is parsed and the answers for both parts are shown.
- if
<options>
are empty input is read from stdin - if
--file <file>
is passed input is read from the<file>
- if
--example
is passed, the example input for the corresponsing day is downloaded, saved in.cache/
and passed as input. - if
--real
is passed, the puzzle input for hte corresponding day is downloaded, saved in.cache/
and passed as input. If a user session isn't found in.cache
you are prompted to provide it and after that it's saved.
cargo test day_00_tests
This command runs the tests in the day_00_tests
module. You can also use cargo test
to run all tests.
- Copy
src/bin/day_00.rs
tosrc/bin/day_##.rs
. - Update the name of the struct and all mentions in your new file.
- Change
DAY_NUMBER
and possiblySolutionResult
if the output isn't an integer.