error checking for Grid
This commit is contained in:
@@ -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; }
|
||||
|
Reference in New Issue
Block a user