aocpp/2019/05.cpp
2023-01-31 09:15:25 -08:00

26 lines
576 B
C++

#include <iostream>
#include <utility>
#include <aocpp/Startup.hpp>
#include <intcode/intcode.hpp>
using namespace intcode;
namespace {
auto Compute(Machine machine, ValueType d) -> ValueType {
ValueType last_output = -1;
Run(machine,
[=]() { return d; },
[&](auto o) { last_output = o; });
return last_output;
}
} // namespace
auto Main(std::istream & in, std::ostream & out) -> void
{
auto machine = Machine{ParseStream(in)};
out << "Part 1: " << Compute(machine, 1) << std::endl;
out << "Part 2: " << Compute(std::move(machine), 5) << std::endl;
}