From 4b3d1ee85a923b3125d024bc989ebfb4071f92ba Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Tue, 17 Dec 2024 21:34:38 +0100 Subject: [PATCH] day_12: init --- src/advent_of_code/thu_12.rs | 22 +++++++++++++++++++--- src/advent_of_code/types.rs | 13 +++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/advent_of_code/thu_12.rs b/src/advent_of_code/thu_12.rs index 3efb98e..b7b1be3 100644 --- a/src/advent_of_code/thu_12.rs +++ b/src/advent_of_code/thu_12.rs @@ -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 { + 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 diff --git a/src/advent_of_code/types.rs b/src/advent_of_code/types.rs index 09ebedc..86f1a04 100644 --- a/src/advent_of_code/types.rs +++ b/src/advent_of_code/types.rs @@ -90,3 +90,16 @@ pub type StoneList = Vec; // Garden Groups pub type Plant = char; pub type Garden = Vec>; + +#[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, +} + +pub type PlotList = Vec;