diff --git a/src/day09/main.rs b/src/day09/main.rs index 0a84770..6db5201 100644 --- a/src/day09/main.rs +++ b/src/day09/main.rs @@ -19,7 +19,7 @@ fn main() -> Result<()> { Ok(()) } -struct XMASDecoder { +pub struct XMASDecoder { input: Vec, } @@ -36,17 +36,17 @@ impl TryFrom<&str> for XMASDecoder { } impl XMASDecoder { - fn find_continues(&self, target: i64) -> Option<&[i64]> { + pub fn find_continues(&self, target: i64) -> Option<&[i64]> { for offset in 0..self.input.len() { let slice = &self.input[offset..self.input.len()]; - if let Some(found) = Self::find_sum(slice, target) { + if let Some(found) = Self::find_sum_slice(slice, target) { return Some(found); } } None } - fn find_sum(slice: &[i64], target: i64) -> Option<&[i64]> { + fn find_sum_slice(slice: &[i64], target: i64) -> Option<&[i64]> { let mut offset = 0; let mut sum = 0; for i in slice { @@ -61,7 +61,7 @@ impl XMASDecoder { None } - fn decode(&self) -> Option { + pub fn decode(&self) -> Option { self.input .windows(26) .into_iter() @@ -83,7 +83,7 @@ impl XMASDecoder { } #[derive(Error, Debug)] -enum Errors { +pub enum Errors { #[error("invalid input")] InvalidInput, }