error checking for Grid

This commit is contained in:
Eric Mertens
2022-11-28 09:20:50 -08:00
parent 9601c42fc5
commit 833f496090
5 changed files with 42 additions and 12 deletions

View File

@@ -22,11 +22,12 @@ namespace {
auto Ski(Grid const& grid, Coord step) -> std::size_t
{
std::size_t const w = grid.rows[0].size();
std::size_t const w = grid.Cols();
std::size_t const h = grid.Rows();
std::size_t trees {0};
Coord here {0,0};
while(here.y < grid.rows.size()) {
while(here.y < h) {
if (grid[here] == '#') trees++;
here += step;
while (here.x >= w) { here.x -= w; }