aocpp/day02.cpp

29 lines
627 B
C++
Raw Normal View History

2022-11-03 08:15:17 -07:00
#include <iostream>
#include <utility>
#include <intcode.hpp>
namespace {
auto compute(intcode machine, std::int64_t x, std::int64_t y) {
machine.at(1) = x;
machine.at(2) = y;
machine.step();
return machine.at(0);
}
}
auto main() -> int {
auto machine = intcode{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;
}
}
}
}