aocpp/2019/05.cpp
2022-11-08 09:13:11 -08:00

25 lines
595 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(int argc, char** argv) -> int {
auto machine = Machine{ParseStream(aocpp::Startup(argc, argv))};
std::cout << "Part 1: " << Compute(machine, 1) << std::endl;
std::cout << "Part 2: " << Compute(std::move(machine), 5) << std::endl;
}