day9: formatting
This commit is contained in:
parent
37b645c341
commit
b84b0b04e2
@ -1,6 +1,6 @@
|
||||
use itertools::Itertools;
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader, Lines};
|
||||
use itertools::Itertools;
|
||||
|
||||
// BOILERPLATE
|
||||
type InputIter = Lines<BufReader<File>>;
|
||||
@ -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<T: BufRead>(input: Lines<T>) -> 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<T: BufRead>(input: Lines<T>) -> 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)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user