aocpp/day02.cpp
Eric Mertens 898ae0521b renames
2022-11-03 14:43:47 -07:00

32 lines
620 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;
machine.Step();
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;
}
}
}
}