From 48c1a1da8b1a0b7249032558eaca03bca9df9d6c Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sun, 10 Dec 2023 06:49:51 +0000 Subject: [PATCH] Day 11 init --- Cargo.toml | 2 +- day11/Cargo.toml | 14 +++++++++++++ day11/src/lib.rs | 50 +++++++++++++++++++++++++++++++++++++++++++++++ day11/src/main.rs | 8 ++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 day11/Cargo.toml create mode 100644 day11/src/lib.rs create mode 100644 day11/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 4676357..63b30bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ "template", "xtask", "day1" -, "day2", "day3", "day4", "day5", "day6", "day7", "day8", "day9", "day10"] +, "day2", "day3", "day4", "day5", "day6", "day7", "day8", "day9", "day10", "day11"] [workspace.dependencies] # Flexible concrete Error type built on std::error::Error diff --git a/day11/Cargo.toml b/day11/Cargo.toml new file mode 100644 index 0000000..a27b560 --- /dev/null +++ b/day11/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "day11" +version = "0.1.0" +edition = "2021" + +[dependencies] +tracing = {workspace = true} +tracing-test = {workspace = true} +anyhow = {workspace = true} +regex = {workspace = true} +lazy_static = {workspace = true} + +[dependencies.utils] +path = "../utils" \ No newline at end of file diff --git a/day11/src/lib.rs b/day11/src/lib.rs new file mode 100644 index 0000000..a2b1ebc --- /dev/null +++ b/day11/src/lib.rs @@ -0,0 +1,50 @@ +use std::io::{BufRead, BufReader}; + +pub type ResultType = u64; + +#[derive(Debug, Default)] +pub struct Solution {} +impl Solution {} + +#[allow(unused_variables, unused_mut)] +impl TryFrom> for Solution { + type Error = std::io::Error; + + fn try_from(reader: BufReader) -> Result { + let mut solution = Self::default(); + for (id, line) in reader.lines().flatten().enumerate() { + // Implement for problem + } + Ok(solution) + } +} +impl utils::Solution for Solution { + type Result = anyhow::Result; + fn analyse(&mut self, _is_full: bool) {} + + fn answer_part1(&self, _is_full: bool) -> Self::Result { + // Implement for problem + Ok(0) + } + + fn answer_part2(&self, _is_full: bool) -> Self::Result { + // Implement for problem + Ok(0) + } +} + +#[cfg(test)] +mod test { + use super::*; + use std::io::BufReader; + + use utils::Solution; + + #[test] + fn read() { + let input = "replace for problem"; + let r = BufReader::new(input.as_bytes()); + let s = crate::Solution::try_from(r).unwrap(); + assert_eq!(0 as ResultType, s.answer_part1(false).unwrap()); + } +} diff --git a/day11/src/main.rs b/day11/src/main.rs new file mode 100644 index 0000000..d4d3d0a --- /dev/null +++ b/day11/src/main.rs @@ -0,0 +1,8 @@ +use anyhow::Result; +use day11::{ResultType, Solution}; + +fn main() -> Result<()> { + utils::log_init(); + + utils::run::(&["sample"], &["full"]) +}