mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-15 02:03:49 +00:00
calculate sum of expanded values
This commit is contained in:
parent
30695d92dd
commit
f86be23eca
@ -9,22 +9,24 @@ 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 structures: Vec<Vec<Vec<i32>>> = sequences
|
let predictions: 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
|
next.first()
|
||||||
|
.unwrap()
|
||||||
|
.last()
|
||||||
|
.unwrap()
|
||||||
|
.clone()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
let sum: i32 = predictions
|
||||||
for seq in structures[0].clone() {
|
.iter()
|
||||||
for n in seq {
|
.sum();
|
||||||
print!("{n} ");
|
|
||||||
}
|
println!("The sum of all prediction values is: '{sum}'.");
|
||||||
println!("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expand(strct: &mut Vec<Vec<i32>>) {
|
fn expand(strct: &mut Vec<Vec<i32>>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user