struct Wordsearch {
cells: Vec<Vec<char>>,
}
Expand description
A wordsearch grid
Fields§
§cells: Vec<Vec<char>>
Implementations§
source§impl Wordsearch
impl Wordsearch
sourcefn find_all(&self, letter: &char) -> Vec<(usize, usize)>
fn find_all(&self, letter: &char) -> Vec<(usize, usize)>
Return a list of all the cell coordinates that contain the provided letter
sourcefn words_from(&self, start: &(usize, usize), length: usize) -> Vec<String>
fn words_from(&self, start: &(usize, usize), length: usize) -> Vec<String>
Find all the words in the 8 possible axes from a given start, of the given length
. These will be cropped if
any overflow the edges of the Wordsearch
.
sourcefn get_word(
&self,
start: &(usize, usize),
length: usize,
delta: &(isize, isize),
) -> String
fn get_word( &self, start: &(usize, usize), length: usize, delta: &(isize, isize), ) -> String
Return the letters along a given delta from a starting coordinate pair, of the given length
. It will be
cropped if it overflows the wordsearch.
sourcefn char_at(&self, (x, y): &(usize, usize)) -> Option<&char>
fn char_at(&self, (x, y): &(usize, usize)) -> Option<&char>
If the coordinate pair given is within the grid return Some(letter)
otherwise None.
sourcefn word_count(&self, search: &String) -> usize
fn word_count(&self, search: &String) -> usize
Solves part 1: Find all instances of the search
word in the wordsearch
sourcefn is_x_mas(&self, coord: &(usize, usize)) -> bool
fn is_x_mas(&self, coord: &(usize, usize)) -> bool
For a given center point, return true if it is the centre of an X-MAS
.
Valid matches are:
M.M M.S S.M S.S
.A. .A. .A. .A.
S.S M.S S.M M.M
sourcefn count_x_masses(&self) -> usize
fn count_x_masses(&self) -> usize
Solves part 2: Find all the A’s in the grid and count those that are the center of an X-MAS
Trait Implementations§
source§impl Debug for Wordsearch
impl Debug for Wordsearch
source§impl FromStr for Wordsearch
impl FromStr for Wordsearch
source§impl PartialEq for Wordsearch
impl PartialEq for Wordsearch
impl Eq for Wordsearch
impl StructuralPartialEq for Wordsearch
Auto Trait Implementations§
impl Freeze for Wordsearch
impl RefUnwindSafe for Wordsearch
impl Send for Wordsearch
impl Sync for Wordsearch
impl Unpin for Wordsearch
impl UnwindSafe for Wordsearch
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.