day_12: nit
This commit is contained in:
@@ -8,9 +8,10 @@
|
|||||||
// mod sun_08;
|
// mod sun_08;
|
||||||
// mod mon_09;
|
// mod mon_09;
|
||||||
// mod tue_10;
|
// mod tue_10;
|
||||||
|
// mod wed_11;
|
||||||
|
mod thu_12;
|
||||||
mod types;
|
mod types;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod wed_11;
|
|
||||||
|
|
||||||
use types::*;
|
use types::*;
|
||||||
|
|
||||||
@@ -83,11 +84,18 @@ pub fn historian_hysteria() {
|
|||||||
// tue_10::hoof_it("./assets/day_10_trail_map_input");
|
// tue_10::hoof_it("./assets/day_10_trail_map_input");
|
||||||
// println!("The trail head sum score is {}", trailhead_score);
|
// println!("The trail head sum score is {}", trailhead_score);
|
||||||
// println!("The full trail head sum score is {}", full_trailhead_score);
|
// println!("The full trail head sum score is {}", full_trailhead_score);
|
||||||
let blink_count: usize = 25;
|
// let blink_count: usize = 25;
|
||||||
let stone_count =
|
// let stone_count =
|
||||||
wed_11::plutonian_pebbles("./assets/day_11_stone_arrangement_input", blink_count);
|
// wed_11::plutonian_pebbles("./assets/day_11_stone_arrangement_input", blink_count);
|
||||||
println!(
|
// println!(
|
||||||
"The total of stones after {} is {}",
|
// "The total of stones after {} is {}",
|
||||||
blink_count, stone_count
|
// 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
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/advent_of_code/thu_12.rs
Normal file
7
src/advent_of_code/thu_12.rs
Normal 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);
|
||||||
|
}
|
||||||
@@ -86,3 +86,7 @@ pub type TrailMap = Vec<Vec<TrailPosition>>;
|
|||||||
pub type StoneCount = usize;
|
pub type StoneCount = usize;
|
||||||
pub type Stone = usize;
|
pub type Stone = usize;
|
||||||
pub type StoneList = Vec<Stone>;
|
pub type StoneList = Vec<Stone>;
|
||||||
|
|
||||||
|
// Garden Groups
|
||||||
|
pub type Plant = char;
|
||||||
|
pub type Garden = Vec<Vec<char>>;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
|
use std::io::read_to_string;
|
||||||
use std::ops::Sub;
|
use std::ops::Sub;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -218,6 +219,20 @@ pub fn read_stone_arrangement(input: &str) -> StoneList {
|
|||||||
stone_list
|
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
|
pub fn calc_distance<T>(num_1: T, num_2: T) -> T
|
||||||
where
|
where
|
||||||
T: PartialOrd + Sub<Output = T>,
|
T: PartialOrd + Sub<Output = T>,
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ pub fn plutonian_pebbles(input: &str, blink_count: usize) -> StoneCount {
|
|||||||
stone_list.len()
|
stone_list.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_rules(stone_list: StoneList, blink_count: usize) -> StoneList {
|
fn apply_rules(mut stone_list: StoneList, blink_count: usize) -> StoneList {
|
||||||
let mut new_stone_list = stone_list.clone();
|
|
||||||
|
|
||||||
for _ in 0..blink_count {
|
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 {
|
fn blink(stone_list: StoneList) -> StoneList {
|
||||||
|
|||||||
Reference in New Issue
Block a user