This is a relatively generalized Rust setup for advent of code. The input data for each challenge is fetched and cached locally.
- Clone repo
- Install rust (see https://www.rust-lang.org/tools/install)
- Copy the value of the Advent of Code session cookie from your browser's devtools.
- Add that value with no whitespace to a new file "session_cookie.txt" in the root of the directory. (e.g.
echo -n "$cookie_value" > session_cookie.txt
) - Execute
cargo run -- 1
from directory root to execute the challenge for day 1. - Bootstrapped files also have a "part_two" boolean you can use to handle the second part of the challenge. Just pass --p2 or --part-two to set it to true -- this way you can keep both versions of the code :)
Run ./bin/add-day.sh $day
, where $day
is a number. This will bootstrap everything and should compile immediately. You can optionally pass another argument to set the function name, like ./bin/add-day.sh 10 fun_holidays
. You can keep the default naming scheme or use something that describes the challenge at hand :)
- Create a new year directory like y2023. (Should follow this same format.)
- Copy the mod.rs file from an existing year to this new directory.
- Remove the
mod dayX;
lines, as well as everything in the match statement except the base error case. It should then be mostly empty. - Change the year name at the top of
src/main.rs
. (Both AOC_YEAR and the mod line for the year. We don't need to add the module for other years that we won't use.) - Run
./bin/add-day.sh 1
to create the first day file -- this will ultimately update the year's mod.rs file. From here you can just add new days above!