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

namespace aoc2016 {

int day2(line_view file, char ds[]) {
  int d{0};
  size_t i{0};
  char l{5};
  keybad pad;
  per_line(file, [&d, &l, &pad, &i, &ds](line_view lv) {
    l = pad.touch(l, lv.line, pad.digit_keys);
    // printf("%d\n", l);
    d = d * 10 + l;
    pad.touch(i++, ds, lv.line, pad.diamond_keys);
    return true;
  });
  return d;
}

} // namespace aoc2016