aboutsummaryrefslogtreecommitdiff
path: root/src/2015/day9/aoc.cpp
blob: 95d65bbab7aeb516c0f88df3be4f38b46c130b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "aoc.h"

namespace aoc2015 {
std::pair<int, int> day9(line_view file) {
  world_day9 world;
  per_line(file, [&world](line_view lv) {
    world.parse(lv);
    return true;
  });
  std::pair<int, int> d{INT32_MAX, INT32_MIN};
  for (auto city : world.locations) {
    auto p = world.plan(city);
    if (p.first < d.first) {
      d.first = p.first;
    }
    if (p.second > d.second) {
      d.second = p.second;
    }
  }
  return d;
}

} // namespace aoc2015