aboutsummaryrefslogtreecommitdiff
path: root/src/2019/day10/aoc.cpp
blob: fbcb04962970c676a990526a98189043dc6761c8 (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
30
31
32
#include "aoc.h"
#include <algorithm>

namespace aoc2019 {

std::pair<int, int> day10(line_view file) {
  belt b;
  int r{0};
  per_line(file, [&b, &r](line_view lv) {
    b.load(lv, r++);
    return true;
  });

  // b.print();

  int observe{0};
  int max{0};

  b.iterate([&observe, &max, &b](belt::pos p){
    if (b.get(p) == '#') {
      observe = 0;
      b.count(p, &observe);
      if (observe > max) {
        max = observe;
      }
    }
  });

  return {max, 0};
}

} // namespace aoc2019