aocpp/day02.cpp
2022-11-04 08:29:02 -07:00

32 lines
619 B
C++

#include <iostream>
#include <utility>
#include <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 {
auto machine = Machine{ParseStream(std::cin)};
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;
}
}
}
}