diff options
Diffstat (limited to 'src/2018/day6/aoc.h')
-rw-r--r-- | src/2018/day6/aoc.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/2018/day6/aoc.h b/src/2018/day6/aoc.h index 9bb86d7..6e5b96f 100644 --- a/src/2018/day6/aoc.h +++ b/src/2018/day6/aoc.h @@ -83,11 +83,13 @@ struct space_board { std::vector<point> ps; space_board(int x, int y) : rows(y), cols(x), ps(x * y, {-1, INT32_MAX}){}; - void count(std::vector<int>& area) { - for (int y = 0; y < cols; y++) { - for (int x = 0; x < rows; x++) { - auto p = ps[y * rows + x]; - if (x == 0 || y == 0 || x == rows - 1 || y == cols - 1) { + int size() const noexcept { return rows * cols; } + + void count(std::vector<int>& area) const noexcept { + for (int y = 0; y < rows; y++) { + for (int x = 0; x < cols; x++) { + auto& p = ps[y * rows + x]; + if (x == 0 || y == 0 || x == cols - 1 || y == rows - 1) { area[p.id] = INT32_MAX; } if (area[p.id] < INT32_MAX) { |