34 lines
713 B
C++
34 lines
713 B
C++
#include <iostream>
|
|
#include <utility>
|
|
|
|
#include <aocpp/Startup.hpp>
|
|
#include <intcode/intcode.hpp>
|
|
|
|
using namespace intcode;
|
|
|
|
namespace {
|
|
|
|
auto Compute(Machine machine, ValueType x, ValueType y) {
|
|
machine.At(1) = x;
|
|
machine.At(2) = y;
|
|
Step(machine);
|
|
return machine.At(0);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
auto main(int argc, char** argv) -> int {
|
|
auto fin = aocpp::Startup(argc, argv);
|
|
auto machine = Machine{ParseStream(fin)};
|
|
|
|
std::cout << "Part 1: " << Compute(machine, 12, 2) << std::endl;
|
|
|
|
for (std::int64_t i = 0; i < 100; i++) {
|
|
for (std::int64_t j = 0; j < 100; j++) {
|
|
if (19690720 == Compute(machine, i, j)) {
|
|
std::cout << "Part 2: " << 100 * i + j << std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|