struct Garden {
plots: Vec<Vec<char>>,
}
Expand description
A grid of plots containing regions of different crops
Fields§
§plots: Vec<Vec<char>>
Implementations§
source§impl Garden
impl Garden
sourcefn get(&self, (r, c): (usize, usize)) -> Option<char>
fn get(&self, (r, c): (usize, usize)) -> Option<char>
Get the contents of a given plot, None if the coordinates are outside the garden
sourcefn walk_region(&self, start: (usize, usize)) -> Region
fn walk_region(&self, start: (usize, usize)) -> Region
Do a modified bucket fill to determine the plots that make up the region that includes the starting plot. When an edge is encountered store the side of the plot it is on for later corner detection.
sourcefn iter_plots<'a>(&'a self) -> impl Iterator<Item = (usize, usize)> + 'a
fn iter_plots<'a>(&'a self) -> impl Iterator<Item = (usize, usize)> + 'a
Iterate over each plots’ coordinates in the garden
sourcefn find_regions(&self) -> Vec<Region>
fn find_regions(&self) -> Vec<Region>
Return all the distinct crop regions in the garden
sourcefn total_fencing_cost(&self) -> usize
fn total_fencing_cost(&self) -> usize
The total cost to fence all the regions in the garden
sourcefn total_fencing_cost_with_discount(&self) -> usize
fn total_fencing_cost_with_discount(&self) -> usize
The total cost to fence all the regions in the garden after applying the “bulk discount”
Trait Implementations§
impl Eq for Garden
impl StructuralPartialEq for Garden
Auto Trait Implementations§
impl Freeze for Garden
impl RefUnwindSafe for Garden
impl Send for Garden
impl Sync for Garden
impl Unpin for Garden
impl UnwindSafe for Garden
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.