diff --git a/day07.cpp b/day07.cpp index 65ee93c..59e39a4 100644 --- a/day07.cpp +++ b/day07.cpp @@ -24,7 +24,7 @@ auto Feed(R &&s, ValueType start) -> std::optional { for (auto &m : amps) { auto e = Step(m); if (auto i = std::get_if(&e)) { - i->pos = start; + i->input = start; start = StepOutput(m); } else { return {}; diff --git a/day23.cpp b/day23.cpp index 0dbc6fa..a1f7eb5 100644 --- a/day23.cpp +++ b/day23.cpp @@ -19,7 +19,7 @@ using Ethernet = std::deque; auto BuildNetwork(Machine m) -> std::vector { std::vector machines; - auto& i = std::get(Step(m)).pos; + auto& i = std::get(Step(m)).input; for (i = 0; i < 50; i++) { machines.push_back(m); } @@ -32,7 +32,7 @@ auto Interact(Ethernet & ethernet, Machine & m, std::optional p) -> voi switch (e.index()) { default: throw std::runtime_error{"unexpected halt"}; case 0: { - auto& i = std::get<0>(e).pos; + auto& i = std::get<0>(e).input; if (p) { i = p->x; StepInput(m, p->y); @@ -43,7 +43,7 @@ auto Interact(Ethernet & ethernet, Machine & m, std::optional p) -> voi return; } case 1: { - auto d = std::get<1>(e).val; + auto d = std::get<1>(e).output; auto x = StepOutput(m); auto y = StepOutput(m); ethernet.push_back({d, {x,y}}); diff --git a/lib/include/intcode/Interpreter.hpp b/lib/include/intcode/Interpreter.hpp index 2fe2fdd..d786e1c 100644 --- a/lib/include/intcode/Interpreter.hpp +++ b/lib/include/intcode/Interpreter.hpp @@ -9,11 +9,11 @@ namespace intcode { struct Input { -ValueType &pos; +ValueType &input; }; struct Output { -ValueType val; +ValueType output; }; struct Halt {}; @@ -32,8 +32,8 @@ template Fin, std::invocable Fout, std::i auto Advance(Machine & machine, Fin input, Fout output, Fhalt halt) { return std::visit(overloaded{ [&](Halt) { return halt(); }, - [&](Input i) { return input(i.pos); }, - [&](Output o) { return output(o.val); }, + [&](Input i) { return input(i.input); }, + [&](Output o) { return output(o.output); }, }, Step(machine)); } diff --git a/lib/src/Interpreter.cpp b/lib/src/Interpreter.cpp index 41abde5..85ce251 100644 --- a/lib/src/Interpreter.cpp +++ b/lib/src/Interpreter.cpp @@ -6,11 +6,11 @@ BadInstruction::BadInstruction(char const* what) : std::runtime_error{what} {} auto StepInput(Machine & m, ValueType input) -> void { - std::get(Step(m)).pos = input; + std::get(Step(m)).input = input; } auto StepOutput(Machine & m) -> ValueType { - return std::get(Step(m)).val; + return std::get(Step(m)).output; } auto Step(Machine & m) -> std::variant {