From b84b0b04e25d615d332094e5bd40322fcc895abe Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Fri, 8 Dec 2023 21:41:30 -0800 Subject: [PATCH] day9: formatting --- 9/src/main.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/9/src/main.rs b/9/src/main.rs index 3f729f6..3b64d5e 100644 --- a/9/src/main.rs +++ b/9/src/main.rs @@ -1,6 +1,6 @@ +use itertools::Itertools; use std::fs::File; use std::io::{BufRead, BufReader, Lines}; -use itertools::Itertools; // BOILERPLATE type InputIter = Lines>; @@ -34,12 +34,8 @@ impl From<&str> for History { impl History { fn build_row(&mut self) { let last = self.0.last().unwrap(); - self.0.push( - last.iter() - .tuple_windows() - .map(|(a, b)| b - a) - .collect(), - ) + self.0 + .push(last.iter().tuple_windows().map(|(a, b)| b - a).collect()) } fn build(&mut self) { @@ -76,7 +72,10 @@ fn problem1(input: Lines) -> i64 { history.extrapolate(); } - histories.iter().map(|history| history.0.first().unwrap().last().unwrap()).sum() + histories + .iter() + .map(|history| history.0.first().unwrap().last().unwrap()) + .sum() } // PROBLEM 2 solution @@ -87,7 +86,10 @@ fn problem2(input: Lines) -> i64 { history.extrapolate2(); } - histories.iter().map(|history| history.0.first().unwrap().first().unwrap()).sum() + histories + .iter() + .map(|history| history.0.first().unwrap().first().unwrap()) + .sum() } #[cfg(test)]