aboutsummaryrefslogtreecommitdiff
path: root/src/2022/day8/aoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/2022/day8/aoc.cpp')
-rw-r--r--src/2022/day8/aoc.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/2022/day8/aoc.cpp b/src/2022/day8/aoc.cpp
index 94ddf69..ff69ecc 100644
--- a/src/2022/day8/aoc.cpp
+++ b/src/2022/day8/aoc.cpp
@@ -2,7 +2,28 @@
namespace aoc2022 {
std::pair<int,int> day8(line_view file) {
- return {0, 0};
+ trees ts;
+ int r{0};
+ per_line(file, [&r, &ts](line_view lv){
+ ts.load(r++, lv);
+ return true;
+ });
+
+ // ts.print();
+
+ int visiable{0};
+ int score{0};
+ for (int y = 0; y < trees::grid; y++) {
+ for (int x = 0; x < trees::grid; x++) {
+ visiable += (int) ts.visiable({x, y});
+ int s = ts.score({x,y});
+ if (s > score) {
+ score = s;
+ }
+ }
+ }
+
+ return {visiable, score};
}
}