mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-15 02:03:49 +00:00
isolate into part one function
This commit is contained in:
parent
f86be23eca
commit
97c5310ead
@ -9,19 +9,30 @@ pub fn main() {
|
|||||||
let input = split_inputs(lines, &r"\s+");
|
let input = split_inputs(lines, &r"\s+");
|
||||||
|
|
||||||
let sequences = convert_num(input);
|
let sequences = convert_num(input);
|
||||||
let predictions: Vec<i32> = sequences
|
let structures: Vec<Vec<Vec<i32>>> = sequences
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
let current = s.to_vec();
|
let current = s.to_vec();
|
||||||
let mut next = extra_diff(current);
|
let mut next = extra_diff(current);
|
||||||
expand(&mut next);
|
expand(&mut next);
|
||||||
next.first()
|
next
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
part_one(&structures);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part_one(strcts: &Vec<Vec<Vec<i32>>>) {
|
||||||
|
let predictions: Vec<i32> = strcts
|
||||||
|
.iter()
|
||||||
|
.map(|seq|
|
||||||
|
seq
|
||||||
|
.first()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.last()
|
.last()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone()
|
.clone()
|
||||||
})
|
).collect();
|
||||||
.collect();
|
|
||||||
let sum: i32 = predictions
|
let sum: i32 = predictions
|
||||||
.iter()
|
.iter()
|
||||||
.sum();
|
.sum();
|
||||||
|
Loading…
Reference in New Issue
Block a user