Programaticly get your puzzle input and submit answers, in Rust.
Might be useful for lazy Rustaceans and speed hackers.
Yes, this is wimglenn's aocd
Python-package, but for Rust. And
yes, this too tries to cache everything it gets from Advent of Code to spare their servers.
Spoiler: This example does in fact solve one of the AoC puzzles.
```rust use aocd::*;
fn main() {
let mut elves: Vec<_> = input!()
.split("\n\n")
.map(|e| e.lines().map(|l| l.parse::
submit!(1, elves.last().unwrap());
submit!(2, elves.iter().rev().take(3).sum::<u32>());
} ```
You need to provide your AoC session token in order for this crate to get your personal puzzle input and to be able to
submit answers for you. This is a cookie which is set when you login to AoC. You can find it with your browser
inspector. See this issue for a how-to. You can provide it to
aocd
use any of the following alternatives:
```bash
mkdir -p ~/.config/aocd echo "your session cookie here" > ~/.config/aocd/token
export AOC_SESSION="or here"
export AOC_TOKEN="or here"
echo "or here" > somefile export AOCTOKENPATH=somefile ```
Next, add the crate to your dependencies:
bash
cargo add aocd
In your code, annotate your main function with #[aocd(year, day)]
, and then use the macros input!()
and
submit!(part, answer)
to get your puzzle input and submit anawers, respectively. See the example above.