🎄⭐🎄⭐🎄 Advent of Code 🎄⭐🎄⭐🎄
This is my rust template for solving AdventOfCode (aoc) tasks. It is meant to be used with cargo generate.
cargo generate https://github.com/jgpr-code/cargo_aoc_template.git
cargo-generate
has support for setting up favorite templates locally.
This is how you can do it:
Create a cargo-generate.toml
in your $HOME\.cargo
folder with the
following contents:
[favorites.aoc]
description = "Rust template for Advent of Code"
git = "https://github.com/jgpr-code/cargo_aoc_template"
Afterwards usage simply becomes:
cargo generate aoc
Way easier to remember. Nice👍
This template uses a virtual rust workspace, containing a common
library crate and dayXY
binary crates.
The common
library initially offers the Answer
struct used in the days and a more
ergonomic regx
macro for Rusts regex library.
Additionally, it has some utility code to support the test code.
The templates tests require a nightly installation of Rust.
rustup toolchain install nightly
- Open the workbench just for your
dayXY
at hand. - Populate the contents of
input
andtest
with your input from the website or with aoc-cli (aoc d -Io
) - Write an input parser in the function
parse_input
returning a customizedInput
struct (feel free to rename it) - Write the solutions in
solve_one
andsolve_two
- Test your solutions with the updated tests by running
cargo test <one|two> [-r]
- ⭐⭐