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};
|
use crate::common::{convert_num, read_file, split_inputs, split_lines};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn part_two() {
|
||||||
let name = "day09";
|
unimplemented!();
|
||||||
println!("Executing module '{name}' entrypoint . . . ");
|
}
|
||||||
|
|
||||||
let content = read_file(name);
|
pub fn part_one() {
|
||||||
let lines = split_lines(&content);
|
let sequences = setup();
|
||||||
let input = split_inputs(lines, &r"\s+");
|
let predictions: Vec<i32> = sequences
|
||||||
|
|
||||||
let sequences = convert_num(input);
|
|
||||||
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
|
next.first()
|
||||||
})
|
|
||||||
.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();
|
||||||
@ -99,3 +86,13 @@ fn seq_diff(seq: Vec<i32>) -> Vec<i32> {
|
|||||||
|
|
||||||
diff
|
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() {
|
fn main() {
|
||||||
println!("Executing main entrypoint . . . ");
|
println!("Executing main entrypoint . . . ");
|
||||||
day09::main();
|
day09::part_one();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user