mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-15 02:03:49 +00:00
better daily partition isolation
This commit is contained in:
parent
97c5310ead
commit
ea0ffa5229
@ -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 . . . ");
|
||||
pub fn part_two() {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
let content = read_file(name);
|
||||
let lines = split_lines(&content);
|
||||
let input = split_inputs(lines, &r"\s+");
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ mod day09;
|
||||
|
||||
fn main() {
|
||||
println!("Executing main entrypoint . . . ");
|
||||
day09::main();
|
||||
day09::part_one();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user