aboutsummaryrefslogtreecommitdiff
path: root/src/2021/day2/aoc.cpp
blob: 80b43ac8e97cf8f838e6469e11adabeb91579163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "aoc.h"

namespace aoc2021 {

std::pair<int, int> day2(line_view file) {
  meters m1{0, 0};
  meters m2{0, 0};
  int aim{0};
  per_line(file, [&m1, &m2, &aim](line_view lv) {
    m1.apply(lv);
    m2.apply(lv, &aim);
    return true;
  });
  return {m1.depth * m1.horizontal, m2.depth * m2.horizontal};
}

} // namespace aoc2021