Compare commits

..

2 Commits

Author SHA1 Message Date
9f602bb947
day18: perf: swap dijkstra for bfs for ~30% improvement
All checks were successful
test / AoC 2024 (push) Successful in 1m40s
2024-12-18 15:21:36 -08:00
df01a1fcd0
grid: row and column iterators
All checks were successful
test / AoC 2024 (push) Successful in 1m33s
2024-12-18 12:20:39 -08:00

View File

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