aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2023-01-20 13:08:42 +0800
committerkaiwu <kaiwu2004@gmail.com>2023-01-20 13:08:42 +0800
commit506315e94ec6a5721577958c129bdb3bf94bae89 (patch)
tree449262ce11e578ef5841c4952b104d674134e0c2
parent957d0f9f9b0c8c8c6889e496e807e178ae1a10da (diff)
downloadadvent-of-code-506315e94ec6a5721577958c129bdb3bf94bae89.tar.gz
advent-of-code-506315e94ec6a5721577958c129bdb3bf94bae89.zip
2016 day11 remodel
-rw-r--r--src/2016/day11/aoc.cpp70
-rw-r--r--src/2016/day11/aoc.h14
2 files changed, 1 insertions, 83 deletions
diff --git a/src/2016/day11/aoc.cpp b/src/2016/day11/aoc.cpp
index a3b0d63..c79c790 100644
--- a/src/2016/day11/aoc.cpp
+++ b/src/2016/day11/aoc.cpp
@@ -1,5 +1,4 @@
#include "aoc.h"
-#include <set>
// F4 . . . . . . . . . . .
// F3 . . . . . . . HG HM RG RM
@@ -44,72 +43,5 @@ int next_floor(int f) {
return f + df;
}
-struct rstatus {
- ritem item;
- bool matched = false;
- bool fried = false;
-};
-
-static void check(size_t i, std::vector<rstatus>& rs) {
- if (i < rs.size()) {
- auto& r = rs[i];
- if (!r.matched) {
- for (size_t x = i + 1; x < rs.size(); x++) {
- auto& r0 = rs[x];
- if (r0.matched)
- continue;
- if (r.item.match(r0.item)) {
- r.matched = true;
- r0.matched = true;
- break;
- }
- if (r.item.fried_with(r0.item)) {
- r.fried = true;
- r0.fried = true;
- }
- }
- }
- check(i + 1, rs);
- }
-}
-
-bool isfine(const std::set<ritem>& rs) {
- std::vector<rstatus> vs;
- for (auto& r : rs) {
- vs.emplace_back(r, false, false);
- }
- check(0, vs);
- for (auto& s : vs) {
- if (s.fried && !s.matched) {
- return false;
- }
- }
- return true;
-}
-
-bool isgood(const std::set<ritem>& rs) { // elevator
- return rs.size() > 0 && rs.size() <= 2 && isfine(rs);
-}
-
-void setup_demo(std::vector<std::set<ritem>>& floors) {
- std::set<ritem> f0 = {{chip, 0}, {chip, 1}};
- std::set<ritem> f1 = {{gen, 0}};
- std::set<ritem> f2 = {{gen, 1}};
- std::set<ritem> f3 = {};
- floors = {f0, f1, f2, f3};
-}
-
-void setup_input(std::vector<std::set<ritem>>& floors) {
- std::set<ritem> f0 = {{chip, 0}, {gen, 0}, {gen, 1}, {gen, 2}};
- std::set<ritem> f1 = {{chip, 1}, {chip, 2}};
- std::set<ritem> f2 = {{chip, 3}, {gen, 3}, {chip, 4}, {gen, 4}};
- std::set<ritem> f3 = {};
- floors = {f0, f1, f2, f3};
-}
-
-std::pair<int64_t, int64_t> day11(line_view) {
- std::vector<std::set<ritem>> floors;
- setup_demo(floors);
- return {0, 0};
-}
+std::pair<int64_t, int64_t> day11(line_view) { return {0, 0}; }
} // namespace aoc2016
diff --git a/src/2016/day11/aoc.h b/src/2016/day11/aoc.h
index 5c89c3e..0206714 100644
--- a/src/2016/day11/aoc.h
+++ b/src/2016/day11/aoc.h
@@ -36,19 +36,5 @@
namespace aoc2016 {
-enum rtype {
- gen,
- chip,
-};
-
-struct ritem {
- rtype t;
- int id;
-
- friend bool operator<(ritem r1, ritem r2) { return r1.id < r2.id ? true : r1.id > r2.id ? false : r1.t < r2.t; }
- bool match(ritem r) const noexcept { return id == r.id && t != r.t; }
- bool fried_with(ritem r) const noexcept { return id != r.id && t != r.t; }
-};
-
std::pair<int64_t, int64_t> day11(line_view);
} // namespace aoc2016