Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxdeviant/adventurous
A companion crate for solving Advent of Code puzzles.
https://github.com/maxdeviant/adventurous
advent-of-code advent-of-code-2023 rust
Last synced: about 2 months ago
JSON representation
A companion crate for solving Advent of Code puzzles.
- Host: GitHub
- URL: https://github.com/maxdeviant/adventurous
- Owner: maxdeviant
- License: mit
- Created: 2018-12-01T17:12:23.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-03T04:41:01.000Z (about 1 year ago)
- Last Synced: 2024-10-13T21:36:44.881Z (2 months ago)
- Topics: advent-of-code, advent-of-code-2023, rust
- Language: Rust
- Homepage: https://docs.rs/adventurous/
- Size: 44.9 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Adventurous
Adventurous is a companion crate to assist you in solving [Advent of Code](https://adventofcode.com) puzzles.
[![crates.io](https://img.shields.io/crates/v/adventurous.svg)](https://crates.io/crates/adventurous)
[![docs.rs](https://docs.rs/adventurous/badge.svg)](https://docs.rs/adventurous)
[![license](https://img.shields.io/crates/l/adventurous.svg)](https://github.com/maxdeviant/adventurous/blob/main/LICENSE)## Installation
```toml
[dependencies]
adventurous = "0.3.0"
```## Examples
### Solving a puzzle
```rust no_run
use adventurous::Input;
use anyhow::Result;#[adventurous::part_one]
fn part_one(input: &Input) -> Result {
Ok(input
.traverse(|line| {
// Do something with the line...
line.parse::()
})?
.sum())
}#[adventurous::part_two]
fn part_two(_input: &Input) -> Result {
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.
```rust
use adventurous::Input;
use anyhow::Result;#[adventurous::part_one(answer = "73")]
fn part_one(input: &Input) -> Result {
Ok(input
.traverse(|line| {
// Do something with the line...
line.parse::()
})?
.sum())
}#[cfg(test)]
mod tests {
use super::*;adventurous::test_solutions!();
}