1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! This crate provides a framework for easily running Advent of Code challenges.
//! ---
//! # Basic Usage
//!
//! ```rust
//! use aoc_runner::{AOCRunner, Challenge, ChallengePart};
//! use aoc_runner::input::from_file;
//!
//! fn main() {
//! AOCRunner::new(ExampleChallenge::new())
//! .add_example(from_file("example.txt"), 42, ChallengePart::Part1)
//! .add_example(from_file("example.txt"), 233, ChallengePart::Part2)
//! .add_example(from_file("example_2.txt"), 402, ChallengePart::Part2)
//! .run(from_file("input.txt"));
//! }
//! ```
//! ---
//! # Features
//!
//! ## The DataLoader Trait
//! The `DataLoader` trait is used to provide the input data to the challenge.
//! It consists of one function, `load`, which returns a `Vec<String>`.
//!
//! The create provides a few functions for loading the input data from different sources such as files, string and via https.
//!
//! ## The Challenge<T> Trait
//! The `Challenge<T>` trait is used to provide the solution to the challenge.
//! The trait is generic over `T` which is the type of the result.
//! So this trait can be implemented for challenges with different result types (eg. Integers or Strings).
//!
//! It consists of two functions, `part1` and `part2`, which are used to provide the solution to the respective part of the challenge.
//! The functions take a `Vec<String>` as input and return an `Option<T>`.
//!
//! ## Examples
//! The struct `AOCRunner`` provides a function `add_example` which is used to add examples to the challenge.
//! This way the user can provide examples for the challenge and check their solution.
//! The function takes a `DataLoader`, the expected result and the corresponding part of the Challenge as input.
//! This way the user can provide examples for both parts of the challenge.
//!
//! ## Feedback
//! After showing the result to the user, the framework will ask the user for feedback.
//! The feedback will be saved and used in the next run.
//! It will warn the user if a result is calculated that is too low or too high and therefore prevent the user from entering known incorrect reults again.
//!
//! ---
//! # Goals
//! There are a few goals this crate aims to achieve:
//!
//! ## 1. Provide a simple interface for running challenges
//! The interface of the framework is very simple.
//! It consists of a struct, `AOCRunner`, which is used to run challenges and add examples.
//! It also consists of a trait, `Challenge`, which is implemented by the user to provide the solution to the challenge.
//!
//! ## 2. Provide a flexible and easy way to load the input data
//! The framework provides a few functions for loading the input data from different sources such as files, string and via https.
//! The user can also implement the `DataLoader` trait to provide a custom way of loading the input data.
//!
//! ## 3. Save the result of the challenge for feedback to user
//! After showing the result to the user, the framework will ask the user for feedback.
//! The feedback can be obtained from entering the result into the AoC website.
//! If the result is incorrect, the website will provide a hint to the user wether the result is too low or too high.
//! The framework will save the result and provide the user with additional information in the next run.
//! It will warn the user if a result is calculated that is too low or too high and therefore prevent the user from entering known incorrect reults again.
//! ---
//! # Links
//! - [Advent of Code 2023](https://adventofcode.com/2023)
pub use AOCRunner;
pub use Challenge;
pub use ChallengePart;