#aoc #driver #session

aoc_driver

helper macros and functions for AoC

19 releases

Uses new Rust 2021

new 0.3.4 Dec 4, 2022
0.3.3 Dec 3, 2022
0.2.5 Dec 3, 2022
0.2.2 Nov 29, 2022
0.1.3 Nov 30, 2021

#366 in Rust patterns

Download history 1/week @ 2022-08-14 10/week @ 2022-08-21 21/week @ 2022-09-04 10/week @ 2022-09-11 2/week @ 2022-09-25 2/week @ 2022-10-02 10/week @ 2022-10-30 20/week @ 2022-11-06 2/week @ 2022-11-13 1/week @ 2022-11-20 132/week @ 2022-11-27

155 downloads per month

MIT/Apache

14KB
320 lines

Aoc Helpers

All functionality requires AoC session cookie, which you can get from you browser after logging in

(look in developer tools)

The most obvious way to use this library is with the calculate_and_post function

use aoc_driver::*;

fn solution(i: &str) -> String { unimplemented!() }

let session = std::fs::read_to_string(".session.txt").unwrap();
calculate_and_post(
    &session,
    2020,
    1,
    Part1,
    Some("inputs/2020/1.txt"),
    Some("cache/2022/1.json"),
    solution
).unwrap();

There is an even faster way though using the aoc_magic macro

use aoc_driver::*;

fn solution(i: &str) -> String { unimplemented!() }

let session = std::fs::read_to_string(".session.txt").unwrap();
aoc_magic!(&session, 2020:1:1, solution).unwrap()

This macro does the same as the above function call (including creating an inputs and cache directory), but more concisely


lib.rs:

Aoc Helpers

All functionality requires AoC session cookie, which you can get from you browser after logging in

(look in developer tools)

The most obvious way to use this library is with the calculate_and_post function

use aoc_driver::*;

fn solution(i: &str) -> String { unimplemented!() }

let session = std::fs::read_to_string(".session.txt").unwrap();
calculate_and_post(
    session,
    2020,
    1,
    Part1,
    Some("inputs/2020/1.txt"),
    Some("cache/2022/1.json"),
    solution
).unwrap();

There is an even faster way though using the aoc_magic macro

use aoc_driver::*;

fn solution(i: &str) -> String { unimplemented!() }

let session = std::fs::read_to_string(".session.txt").unwrap();
aoc_magic!(session, 2020:1:1, solution).unwrap()

This macro does the same as the above function call (including creating an inputs and cache directory), but more concisely

Dependencies

~2.1–3.5MB
~93K SLoC