3 releases

0.2.2 Dec 1, 2022
0.2.1 Oct 16, 2022
0.2.0 Oct 16, 2022

#3 in #–

MIT license

35KB
693 lines

Yet Another AOC Helper

crates.io

Getting started

  • Extract the advent of code's session cookie from your browser.
  • Create a new project using the template: cargo generate --git https://github.com/ithinuel/yaah-template.git.
  • Run cargo run --release.
  • Enjoy!

AOC Session

The template stores your session in .cargo/config.toml. Alternatively you can define the environment variable AOC_SESSION.

yaah will automatically download the input file and store it in input/{year}/{day}.txt if it is not present.


lib.rs:

yaah – Yet Another AOC Helper for your Advent Of Code adventures

This crate handles the boilerplate around fetching, running and benchmarking your input parsing and solution implementations. It is inpired by the excellent cargo-aoc cargo extentions.

Setup

This helper will automatically fetch your personnal input file provided you set your AOC session cookie in the AOC_SESSION environment variable. This can be either done through your favorite shell or in a .cargo/config.toml file as such:

[env]
AOC_SESSION = "your super long session secret extracted from your browser's cookie jar"

Note that this .cargo directory can reside in a parent directory of your project allowing you to have a project specific version controlled cargo config file without leaking your session secret.

If you want to benefit from the auto-generated main function, you will need to add a dependency to clap.

clap = { version = "4.0", features = ["derive"] }

If you want to benefit from the auto-generated bench marks, your project's manifest will require these extra elements:

[dependencies]
criterion = "0.4.0"

[[bench]]
# Adjust that name to that of your file in the `./benches` directory.
name = "aoc-bench"
harness = false

For your convenience a template project is availble. Simply bootstrap your Advent of code with:

cargo generate --git https://github.com/ithinuel/yaah-template.git

Dependencies

~5–20MB
~259K SLoC