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
//! A crate that holds solutions to [Advent of Code](https://adventofcode.com)(AoC) puzzles.
//! The solutions are implemented in async rust, thus need an async runtime such as [`tokio`](https://docs.rs/tokio/1.28.1/tokio).
//!
//! # Feature-flags
//! By default, [`Puzzl`] and [`Solve`] traits are provided.
//!
//! To generate solvers for a puzzle using [`solver`],
//! add `solvers` [feature flag] in Cargo.toml
//!
//! If you wish to implement your own solver, and only require some
//! useful utilities, add `toolcase` [feature flag] in Cargo.toml
//!
//! # Examples
//!
//! Two traits [`Puzzl`] and [`Solve`] are provided to interface with the
//! solvers.
//!
//! ```no_run
//! use std::{error, sync::Arc};
//!
//! use aocsol::{puzzle::Puzzl, solver};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn error::Error + Send + Sync>> {
//! let data = "1000\n2000\n\n4000\n\n5000\n6000\n\n7000\n9000";
//! let puzzle = AocPuzzle(Arc::from(data));
//! let solver = solver::solver(puzzle)?; // solver generated
//!
//! let answer_part_one: u32 = solver.part_one().await?.to_string().parse()?;
//! let answer_part_two: u32 = solver.part_two().await?.to_string().parse()?;
//!
//! assert_eq!(16000, answer_part_one);
//! assert_eq!(31000, answer_part_two);
//!
//! Ok(())
//! }
//!
//! // Sturct to hold data.
//! struct AocPuzzle(Arc<str>);
//!
//! // Implement Puzzl<InputType = Arc<str>> to generate solver using aocsol::solver::solver().
//! impl<'input> Puzzl for AocPuzzle {
//! type InputType = Arc<str>;
//!
//! fn year(&self) -> u32 {
//! 2022
//! }
//!
//! fn day(&self) -> u32 {
//! 1
//! }
//!
//! fn data(&self) -> Self::InputType {
//! Arc::clone(&self.0)
//! }
//! }
//! ```
//!
//! [`Puzzl`]: crate::puzzle::Puzzl
//! [`Solve`]: crate::puzzle::Solve
//! [feature flag]: https://doc.rust-lang.org/cargo/reference/features.html#the-features-section
pub
extern crate lazy_static;