mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 21:30:31 +01:00
Implement 2023 day 10 part 1
This commit is contained in:
@@ -146,11 +146,9 @@ pub fn get_both<T>(slice: &mut [T], first: usize, second: usize) -> (&mut T, &mu
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct IndexSet(Vec<u32>);
|
||||
|
||||
#[allow(unused)]
|
||||
impl IndexSet {
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self(Vec::with_capacity(
|
||||
@@ -278,6 +276,12 @@ impl<'a> Grid<'a> {
|
||||
.chunks_exact(self.width)
|
||||
.map(move |row| &row[..width])
|
||||
}
|
||||
|
||||
pub fn find(&self, c: u8) -> Option<(usize, usize)> {
|
||||
let pos = self.data.iter().position(|&d| d == c)?;
|
||||
|
||||
Some((pos % self.width, pos / self.width))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Index<usize> for Grid<'a> {
|
||||
|
||||
Reference in New Issue
Block a user