32 lines
637 B
C++
32 lines
637 B
C++
#include <iostream>
|
|
#include <utility>
|
|
|
|
#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 machine = Startup(argc, argv);
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|