Skip to content

Commit f3d9db0

Browse files
committed
Add points helper function for future
1 parent ef5d7e6 commit f3d9db0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

aoc_utils/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,20 @@ impl<'a> InputParse<'a> for &'a str {
412412
}
413413
}
414414

415+
pub trait MapUtils {
416+
fn points(&self) -> Vec<Point>;
417+
}
418+
419+
impl<T> MapUtils for Vec<Vec<T>> {
420+
fn points(&self) -> Vec<Point> {
421+
self.iter()
422+
.enumerate()
423+
.map(|(x, v)| v.iter().enumerate().map(|(y, _)| Point(x, y)).collect_vec())
424+
.flatten()
425+
.collect_vec()
426+
}
427+
}
428+
415429
/// Extract numbers from regex captures
416430
pub trait ExtractNum {
417431
/// Parse capture group at position to number type

0 commit comments

Comments
 (0)