aboutsummaryrefslogtreecommitdiff
path: root/src/2016/day8/aoc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/2016/day8/aoc.h')
-rw-r--r--src/2016/day8/aoc.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/2016/day8/aoc.h b/src/2016/day8/aoc.h
index d92a8f7..2313bc9 100644
--- a/src/2016/day8/aoc.h
+++ b/src/2016/day8/aoc.h
@@ -7,9 +7,17 @@ template <size_t W, size_t H>
struct grid {
char cells[W * H] = {0};
+ int count() const noexcept {
+ int total{0};
+ for (size_t i = 0; i < ARRAY_SIZE(cells); i++) {
+ total += int(cells[i] == 1);
+ }
+ return total;
+ }
+
void print() {
for (size_t i = 0; i < ARRAY_SIZE(cells); i++) {
- printf("%d", cells[i]);
+ printf("%s", cells[i] == 0 ? "." : "#");
if (i % W == W - 1) {
printf("\n");
}