grid: row and column iterators

This commit is contained in:
2024-12-18 12:20:28 -08:00
parent 2a11e17d92
commit 3712b32634
2 changed files with 101 additions and 17 deletions

View File

@ -99,8 +99,7 @@ pub struct Map {
impl<T: BufRead> From<T> for Map {
fn from(input: T) -> Self {
let grid = Grid::from(input);
let mut visited_from: Grid<DirectionSet> = Grid::new(grid.width() as i64);
visited_from.data.resize(grid.data.len(), DirectionSet::empty());
let visited_from = grid.same_shape(DirectionSet::empty());
let guard_pos = grid.find(&b'^').expect("Guard not found");
let guard_facing = FacingDirection::Up;
Self {