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

33 lines
695 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 machine = Machine{ParseStream(aocpp::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;
}
}
}
}