A rust template for Advent of Code.
- Clone this repo.
- Setup your environment:
export AOC_YEAR=<year>export AOC_SESSION=<Your session key>export AOC_INPUT=<Your input directory>
- Run ONCE:
cargo build - Delete
build.rs- you don't need to build again.
- Download the day's file:
cargo run -- init <day>. The file will be downloaded into theAOC_INPUTdirectory. - Write your code in the "day" files in
src/solutions/dayX.rs - Build and run your code:
cargo run -- run <day> [--part <part>] [--extra arg1 arg2 arg3] [--input path/to/input]- The arguments within [ ] are optional.
- Skipping
--partwill run both part 1 and part 2. - Skipping
--extrawill give an emptyVec<T>of extra args. - Skipping
--inputwill look for the download input inAOC_INPUT.
- The module name is aoc-2020 but the template should work for any year
- The solution files are part of the same crate and so, their dependencies are shared.
build.rsis very brittle and made only for the initial state of the repo.- The author in
Cargo.tomlis me. Change it if you want.
Do not run build.rs after you have started writing your code.