diff --git a/.gitignore b/.gitignore index f4ceea7..bb34ff2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,14 @@ **/target/ + + +# Added by cargo + +/target + + +# Added by cargo +# +# already existing elements were commented out + +#/target +Cargo.lock diff --git a/2021/Cargo.lock b/2021/Cargo.lock index 8464c49..3c24dd1 100644 --- a/2021/Cargo.lock +++ b/2021/Cargo.lock @@ -2,10 +2,22 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "advent" +version = "0.1.0" +dependencies = [ + "anyhow", + "aoc-runner", + "aoc-runner-derive", + "pretty_assertions", + "thiserror", +] + [[package]] name = "advent2021" version = "0.1.0" dependencies = [ + "advent", "ansi_term", "anyhow", "aoc-runner", diff --git a/2021/Cargo.toml b/2021/Cargo.toml index 957d90a..166fb98 100644 --- a/2021/Cargo.toml +++ b/2021/Cargo.toml @@ -12,3 +12,4 @@ aoc-runner = "0.3.0" aoc-runner-derive = "0.3.0" pretty_assertions = "1.0.0" thiserror = "1.0.30" +advent = { path = "../" } diff --git a/2021/src/day13.rs b/2021/src/day13.rs index 3eda843..40cec65 100644 --- a/2021/src/day13.rs +++ b/2021/src/day13.rs @@ -1,13 +1,5 @@ -use std::{ - fmt::{Debug, Error, Formatter}, - num::ParseIntError, - ops::{Index, IndexMut}, - str::FromStr, -}; - -use anyhow::Result; -use aoc_runner_derive::{aoc, aoc_generator}; -use thiserror::Error; +use advent::prelude::*; +use aoc_runner_derive::aoc; struct Image { width: usize, @@ -182,7 +174,7 @@ fn part2(input: &str) -> Result { mod tests { use super::*; - //#[test] + #[test] fn test_part1() -> Result<()> { let input = r#" 6,10 diff --git a/2021/src/day15.rs b/2021/src/day15.rs index 9a899be..c46e09e 100644 --- a/2021/src/day15.rs +++ b/2021/src/day15.rs @@ -1,15 +1,5 @@ -use std::{ - collections::{HashMap, HashSet, VecDeque}, - convert::Infallible, - fmt::{Debug, Error, Formatter}, - num::ParseIntError, - ops::{Index, IndexMut}, - str::FromStr, -}; - -use anyhow::Result; -use aoc_runner_derive::{aoc, aoc_generator}; -use thiserror::Error; +use advent::prelude::*; +use aoc_runner_derive::aoc; struct Image { width: usize, diff --git a/2021/src/day16.rs b/2021/src/day16.rs index e21d33c..92f164e 100644 --- a/2021/src/day16.rs +++ b/2021/src/day16.rs @@ -1,14 +1,5 @@ -use std::{ - fmt::{Debug, Error, Formatter}, - io::Read, - num::ParseIntError, - ops::{Index, IndexMut}, - str::FromStr, -}; - -use anyhow::Result; -use aoc_runner_derive::{aoc, aoc_generator}; -use thiserror::Error; +use advent::prelude::*; +use aoc_runner_derive::aoc; fn hex(b: &u8) -> u8 { if *b >= b'A' { diff --git a/2021/src/lib.rs b/2021/src/lib.rs index c959bfc..e64251e 100644 --- a/2021/src/lib.rs +++ b/2021/src/lib.rs @@ -3,7 +3,7 @@ pub mod day10; pub mod day11; pub mod day12; pub mod day13; -pub mod day14; +//pub mod day14; pub mod day15; pub mod day16; pub mod day2; diff --git a/2021/src/template.rs b/2021/src/template.rs index ed18fea..11dee2e 100644 --- a/2021/src/template.rs +++ b/2021/src/template.rs @@ -1,13 +1,5 @@ -use std::{ - fmt::{Debug, Error, Formatter}, - num::ParseIntError, - ops::{Index, IndexMut}, - str::FromStr, -}; - -use anyhow::Result; +use advent::prelude::*; use aoc_runner_derive::{aoc, aoc_generator}; -use thiserror::Error; #[aoc(dayX, part1)] fn part1(input: &str) -> Result { diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5125c1f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "advent" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.45" +aoc-runner = "0.3.0" +aoc-runner-derive = "0.3.0" +pretty_assertions = "1.0.0" +thiserror = "1.0.30" + +[lib] +name = "advent" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e4f4209 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,13 @@ +pub mod prelude { + pub use std::{ + convert::Infallible, + fmt::{Debug, Error, Formatter}, + io::Read, + num::ParseIntError, + ops::{Index, IndexMut}, + str::FromStr, + }; + + pub use anyhow::Result; + pub use thiserror::Error; +}