day_12: init

This commit is contained in:
2024-12-17 21:34:38 +01:00
parent 8a49944e00
commit 4b3d1ee85a
2 changed files with 32 additions and 3 deletions

View File

@@ -1,7 +1,23 @@
use utils::read_garden_arrangement_input;
use super::*;
pub fn garden_groups(input: &str) {
let garden = read_garden_arrangement_input(input);
let garden = utils::read_garden_arrangement_input(input);
}
pub fn get_plot_list(map: &Garden) -> Plot {
let plot = Plot{}
}
pub fn which_plot_contains_coords(list: &PlotList, coord: Coorinate) -> Option<usize> {
for (plot_index, plot) in list.iter().enumerate() {
if plot.plant_list.contains(coord) {
return Some(plot_index);
}
}
None
}
// Perimeter is calculated looping over the elements and adding every non-member.
//
// mutate the garden on every iteration to avoid exploring already counted areas

View File

@@ -90,3 +90,16 @@ pub type StoneList = Vec<Stone>;
// Garden Groups
pub type Plant = char;
pub type Garden = Vec<Vec<char>>;
#[derive(PartialEq)]
pub struct Coordinate {
pub x: usize,
pub y: usize,
}
pub struct Plot {
pub plant: Plant,
pub side_count: usize,
pub plant_list: Vec<Coordinate>,
}
pub type PlotList = Vec<Plot>;