adventurous

Crates.ioadventurous
lib.rsadventurous
version0.3.0
sourcesrc
created_at2018-12-01 17:30:59.03106
updated_at2023-12-03 04:40:18.800958
descriptionA companion crate for solving Advent of Code puzzles.
homepage
repositoryhttps://github.com/maxdeviant/adventurous
max_upload_size
id99554
size10,893
Marshall Bowers (maxdeviant)

documentation

https://docs.rs/adventurous

README

Adventurous

Adventurous is a companion crate to assist you in solving Advent of Code puzzles.

crates.io docs.rs license

Installation

[dependencies]
adventurous = "0.3.0"

Examples

Solving a puzzle

use adventurous::Input;
use anyhow::Result;

#[adventurous::part_one]
fn part_one(input: &Input) -> Result<usize> {
    Ok(input
        .traverse(|line| {
            // Do something with the line...
            line.parse::<usize>()
        })?
        .sum())
}

#[adventurous::part_two]
fn part_two(_input: &Input) -> Result<usize> {
    todo!()
}

fn main() -> Result<()> {
    adventurous::run("input.txt", part_one, part_two)
}

Regression testing

Once a solution has been solved, you can provide the correct answer for each part using the #[part_one] and #[part_two] attributes.

Calling test_solutions!() inside of your tests module will generate regression tests that ensure the output from your solvers matches the correct answer.

use adventurous::Input;
use anyhow::Result;

#[adventurous::part_one(answer = "73")]
fn part_one(input: &Input) -> Result<usize> {
    Ok(input
        .traverse(|line| {
            // Do something with the line...
            line.parse::<usize>()
        })?
        .sum())
}

#[cfg(test)]
mod tests {
    use super::*;

    adventurous::test_solutions!();
}
Commit count: 32

cargo fmt