aocpp/day02.cpp
2022-11-03 12:53:10 -07:00

32 lines
623 B
C++

#include <iostream>
#include <utility>
#include <intcode.hpp>
using namespace intcode;
namespace {
auto compute(Machine machine, value_type x, value_type y) {
machine.at(1) = x;
machine.at(2) = y;
machine.step();
return machine.at(0);
}
} // namespace
auto main() -> int {
auto machine = Machine{parse_stream(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;
}
}
}
}