| Crates.io | advent-of-utils |
| lib.rs | advent-of-utils |
| version | 0.2.3 |
| created_at | 2024-12-17 17:26:29.074955+00 |
| updated_at | 2024-12-18 17:00:41.827627+00 |
| description | CLI and library to organise and run Advent of Code puzzles |
| homepage | |
| repository | https://github.com/Itron-al-Lenn/Advent-of-Utils |
| max_upload_size | |
| id | 1486500 |
| size | 17,370 |
Advent of Utils helps you solving your Advent of Code challenges. Not by implementing the solutions for you, but by handling the boilerplate work so you can focus on solving the puzzles.
Add this to your Cargo.toml:
[dependencies]
advent-of-utils = "0.2.0"
[lib]
crate-type = ["cdylib"]
Install the CLI using:
cargo install advent-of-utils-cli
Set your Advent of Code session token:
# Linux/MacOS
export AOC_SESSION=your_session_token
# Windows (PowerShell)
$env:AOC_SESSION="your_session_token"
You will find your session token in the cookies on the Advent of Code page when you are logged in.
First, create a new Rust project for your solutions:
cargo new aoc-2023
cd aoc-2023
In your project's lib.rs, use the add_days! macro to generate the boilerplate for your solutions:
use advent_of_utils::add_days;
// Generate modules for days 1 through 25
add_days!(1..=25);
For each day you want to solve, implement the Solution trait in the corresponding module. You need to create a file for all the days you added yet to your macro or the compiler will complain. Here's an example for day 1:
// src/day01.rs
use advent_of_utils::{Solution, AocOption};
pub struct Day01;
impl Solution for Day01 {
fn part1(&self, input: String) -> AocOption {
// Your solution for part 1
1.into()
}
fn part2(&self, input: String) -> AocOption {
// Your solution for part 2
"part2 result".into()
}
}
Once your solutions are implemented and your code compiles you can run the your code through the aou CLI:
# Run a specific day's solution
aou run <YEAR> <DAY>
# Run all implemented solutions
aou run <YEAR>
For more informations on your options for the CLI run:
aou --help
This tool adheres to the automation guidelines outlined in the Advent of Code FAQ on automation: