day_12: init
This commit is contained in:
@@ -1,7 +1,23 @@
|
|||||||
use utils::read_garden_arrangement_input;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub fn garden_groups(input: &str) {
|
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
|
||||||
|
|||||||
@@ -90,3 +90,16 @@ pub type StoneList = Vec<Stone>;
|
|||||||
// Garden Groups
|
// Garden Groups
|
||||||
pub type Plant = char;
|
pub type Plant = char;
|
||||||
pub type Garden = Vec<Vec<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>;
|
||||||
|
|||||||
Reference in New Issue
Block a user