better daily partition isolation

This commit is contained in:
Baipyrus 2024-01-24 23:38:32 +01:00
parent 97c5310ead
commit ea0ffa5229
2 changed files with 21 additions and 24 deletions

View File

@ -1,38 +1,25 @@
use crate::common::{convert_num, read_file, split_inputs, split_lines};
pub fn main() {
let name = "day09";
println!("Executing module '{name}' entrypoint . . . ");
let content = read_file(name);
let lines = split_lines(&content);
let input = split_inputs(lines, &r"\s+");
pub fn part_two() {
unimplemented!();
}
let sequences = convert_num(input);
let structures: Vec<Vec<Vec<i32>>> = sequences
pub fn part_one() {
let sequences = setup();
let predictions: Vec<i32> = sequences
.iter()
.map(|s| {
let current = s.to_vec();
let mut next = extra_diff(current);
expand(&mut next);
next
})
.collect();
part_one(&structures);
}
fn part_one(strcts: &Vec<Vec<Vec<i32>>>) {
let predictions: Vec<i32> = strcts
.iter()
.map(|seq|
seq
.first()
next.first()
.unwrap()
.last()
.unwrap()
.clone()
).collect();
})
.collect();
let sum: i32 = predictions
.iter()
.sum();
@ -99,3 +86,13 @@ fn seq_diff(seq: Vec<i32>) -> Vec<i32> {
diff
}
fn setup() -> Vec<Vec<i32>> {
let name = "day09";
println!("Executing module '{name}' entrypoint . . . ");
let content = read_file(name);
let lines = split_lines(&content);
let input = split_inputs(lines, &r"\s+");
convert_num(input)
}

View File

@ -3,5 +3,5 @@ mod day09;
fn main() {
println!("Executing main entrypoint . . . ");
day09::main();
day09::part_one();
}