This is a template for solving the advent of code challenges in rust. This template makes it easy to keep your solutions organized, and gets rid of the setup. This way you can focus on solving the puzzles, not the setup.
- CLI Arg parsing with clap to easily configure what runs
- By default,
cargo run
will run your most recent day, which is usually what you want. - You can run a specific day with
cargo r -- -d4
(replacing 4 with the day you want to run). or run all of them withcargo run -- -a
.
- By default,
- Solutions are automatically timed so that you have a general idea of execution
time. Of course, make sure to run with the
--release
flag before making any optimizations. - Pretty output: This template makes use of the colored
crate to color and bold output. The results of your code are colored according to
solutions.rs
: blue if you haven't entered a solution yet, green if they match, or red if they don't match. - Tests: If you put your solutions in
solutions.rs
, runningcargo test
will test the current day. This can be helpful if you want to refactor your solution after you solved it. To test every day, runcargo test -- --include-ignored
.
- On GitHub, click "Use this template" then "Create New Repository".
- Download your input, and put it in the
./input/
folder with the formatdXX.txt
. ex.d05.txt
. - Write your day 1 code in
./src/days/d1.rs
. - As you work though the puzzles, increment the
CURRENT_DAY
constant inmain.rs
, so thatcargo run
runs the right puzzle. - When you solve a puzzle, put your solution in
solutions.rs
. This colors your output green or red according to if the solution matches or not, and allows you to docargo test
to test your solutions.
This template is licensed under the CC0 1.0 Universal.
If you see something that could use improvement, or you want to add a feature, open a PR. Any contributions made will be subject to the above license.