aboutsummaryrefslogtreecommitdiff
path: root/src/2016/day10/aoc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/2016/day10/aoc.h')
-rw-r--r--src/2016/day10/aoc.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/2016/day10/aoc.h b/src/2016/day10/aoc.h
index fb3f80b..a7d8d72 100644
--- a/src/2016/day10/aoc.h
+++ b/src/2016/day10/aoc.h
@@ -3,5 +3,30 @@
#include <vector>
namespace aoc2016 {
+
+struct bot {
+ int idx;
+ int vs[2] = {0, 0};
+ std::vector<int> values;
+ bot* outputs[2] = {nullptr, nullptr};
+ bool is_output = false;
+
+ bool can_give() const noexcept { return vs[0] != 0 && vs[1] != 0; }
+ void set(int v) {
+ for (int i = 0; i < 2; i++) {
+ if (vs[i] == 0) {
+ vs[i] = v;
+ break;
+ }
+ }
+ if (vs[0] > vs[1]) {
+ std::swap(vs[0], vs[1]);
+ }
+ }
+
+ void get(int v) { // bot as output
+ values.push_back(v);
+ }
+};
std::pair<int64_t, int64_t> day10(line_view);
-}
+} // namespace aoc2016