diff options
Diffstat (limited to 'src/2016/day11/aoc.cpp')
-rw-r--r-- | src/2016/day11/aoc.cpp | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/src/2016/day11/aoc.cpp b/src/2016/day11/aoc.cpp index c79c790..9a45063 100644 --- a/src/2016/day11/aoc.cpp +++ b/src/2016/day11/aoc.cpp @@ -36,12 +36,74 @@ namespace aoc2016 { int next_floor(int f) { static int df = 1; - if (f == 0) + if (f == 1) df = 1; - if (f == 3) + if (f == 4) df = -1; return f + df; } -std::pair<int64_t, int64_t> day11(line_view) { return {0, 0}; } +void setup_demo(std::vector<ritem>& rs) { + rs.emplace_back(2, 1); + rs.emplace_back(3, 1); +} + +void setup_input(std::vector<ritem>& rs) { + rs.emplace_back(1, 1); + rs.emplace_back(1, 2); + rs.emplace_back(1, 2); + rs.emplace_back(3, 3); + rs.emplace_back(3, 3); +} + +bool all_at(const std::vector<ritem>& rs, int f) { + for (auto& r : rs) { + if (r.fs[0] != f || r.fs[1] != f) { + return false; + } + } + return true; +} + +bool any_at(const std::vector<ritem>& rs, int f) { + for (auto& r : rs) { + if (r.fs[0] == f || r.fs[1] == f) { + return true; + } + } + return false; +} + +bool empty(const std::vector<ritem>& rs, int f) { return !any_at(rs, f); } + +// goal is to get every ritem in rs with value (4,4) +// 1. in every step, modify fs[0] or fs[1] in each ritem +// 2. at minimal 1 must be modified, at most, 2 can be modified +// 3. chip fs[1] can only be modified if +// 3.1 fs[0] == next_floor(fs[1]) +// 3.2 or empty == next_floor(fs[1]) +// 4. only increase fs[0] ?? +// 5. gen fs[0] can only be modified if +// 5.1 fs[1] == next_floor(fs[0]) +// 5.2 or empty == next_floor(fs[0]) +// 6. either modify fs[0] and fs[1] of the same ritem +// or modify two fs[0] or two fs[1] +void move_ritem(int step, int floor, std::vector<ritem>& rs, int* min) { + if (all_at(rs, 4)) { + if (*min > step) { + *min = step; + } + } else { + // int nf = next_floor(floor); + } +} + +std::pair<int64_t, int64_t> day11(line_view) { + std::vector<ritem> rs; + setup_demo(rs); + + int min{INT32_MAX}; + move_ritem(0, 1, rs, &min); + return {0, 0}; +} } // namespace aoc2016 |