diff --git a/src/advent_of_code/mod.rs b/src/advent_of_code/mod.rs index acb77f9..c1c4731 100644 --- a/src/advent_of_code/mod.rs +++ b/src/advent_of_code/mod.rs @@ -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 + // ); } diff --git a/src/advent_of_code/thu_12.rs b/src/advent_of_code/thu_12.rs new file mode 100644 index 0000000..3efb98e --- /dev/null +++ b/src/advent_of_code/thu_12.rs @@ -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); +} diff --git a/src/advent_of_code/types.rs b/src/advent_of_code/types.rs index f0c0bfc..09ebedc 100644 --- a/src/advent_of_code/types.rs +++ b/src/advent_of_code/types.rs @@ -86,3 +86,7 @@ pub type TrailMap = Vec>; pub type StoneCount = usize; pub type Stone = usize; pub type StoneList = Vec; + +// Garden Groups +pub type Plant = char; +pub type Garden = Vec>; diff --git a/src/advent_of_code/utils.rs b/src/advent_of_code/utils.rs index 2d3d747..ab51c59 100644 --- a/src/advent_of_code/utils.rs +++ b/src/advent_of_code/utils.rs @@ -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 = vec![]; + for plant in line.chars() { + garden_row.push(plant); + } + garden.push(garden_row); + } + + garden +} + pub fn calc_distance(num_1: T, num_2: T) -> T where T: PartialOrd + Sub, diff --git a/src/advent_of_code/wed_11.rs b/src/advent_of_code/wed_11.rs index 06d30cd..c3d60ce 100644 --- a/src/advent_of_code/wed_11.rs +++ b/src/advent_of_code/wed_11.rs @@ -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 {