blob: ff69eccf4bc657367e01ef5bd3c1b6521de56055 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "aoc.h"
namespace aoc2022 {
std::pair<int,int> day8(line_view file) {
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};
}
}
|