day_12: nit

This commit is contained in:
2024-12-15 23:19:08 +01:00
parent 49ed857a18
commit 8a49944e00
5 changed files with 45 additions and 13 deletions

View File

@@ -8,9 +8,10 @@
// mod sun_08;
// mod mon_09;
// mod tue_10;
// mod wed_11;
mod thu_12;
mod types;
mod utils;
mod wed_11;
use types::*;
@@ -83,11 +84,18 @@ pub fn historian_hysteria() {
// tue_10::hoof_it("./assets/day_10_trail_map_input");
// println!("The trail head sum score is {}", trailhead_score);
// println!("The full trail head sum score is {}", full_trailhead_score);
let blink_count: usize = 25;
let stone_count =
wed_11::plutonian_pebbles("./assets/day_11_stone_arrangement_input", blink_count);
println!(
"The total of stones after {} is {}",
blink_count, stone_count
);
// let blink_count: usize = 25;
// let stone_count =
// wed_11::plutonian_pebbles("./assets/day_11_stone_arrangement_input", blink_count);
// println!(
// "The total of stones after {} is {}",
// blink_count, stone_count
// );
// let blink_count: usize = 75;
// let stone_count =
// wed_11::plutonian_pebbles("./assets/day_11_stone_arrangement_input", blink_count);
// println!(
// "The total of stones after {} is {}",
// blink_count, stone_count
// );
}

View File

@@ -0,0 +1,7 @@
use utils::read_garden_arrangement_input;
use super::*;
pub fn garden_groups(input: &str) {
let garden = read_garden_arrangement_input(input);
}

View File

@@ -86,3 +86,7 @@ pub type TrailMap = Vec<Vec<TrailPosition>>;
pub type StoneCount = usize;
pub type Stone = usize;
pub type StoneList = Vec<Stone>;
// Garden Groups
pub type Plant = char;
pub type Garden = Vec<Vec<char>>;

View File

@@ -1,4 +1,5 @@
use std::fs::read_to_string;
use std::io::read_to_string;
use std::ops::Sub;
use super::*;
@@ -218,6 +219,20 @@ pub fn read_stone_arrangement(input: &str) -> StoneList {
stone_list
}
pub fn read_garden_arrangement_input(input: &str) -> Garden {
let mut garden: Garden = vec![];
for line in read_to_string(input).unwrap().lines() {
let mut garden_row: Vec<Plant> = vec![];
for plant in line.chars() {
garden_row.push(plant);
}
garden.push(garden_row);
}
garden
}
pub fn calc_distance<T>(num_1: T, num_2: T) -> T
where
T: PartialOrd + Sub<Output = T>,

View File

@@ -8,14 +8,12 @@ pub fn plutonian_pebbles(input: &str, blink_count: usize) -> StoneCount {
stone_list.len()
}
fn apply_rules(stone_list: StoneList, blink_count: usize) -> StoneList {
let mut new_stone_list = stone_list.clone();
fn apply_rules(mut stone_list: StoneList, blink_count: usize) -> StoneList {
for _ in 0..blink_count {
new_stone_list = blink(new_stone_list);
stone_list = blink(stone_list);
}
new_stone_list
stone_list
}
fn blink(stone_list: StoneList) -> StoneList {