#include #include #include #include #include "intcode.hh" std::vector read_input_file() { std::ifstream file("input"); std::vector data; std::string line; while(std::getline(file, line, ',')) data.push_back(std::stoi(line)); return data; } void solve_a(std::vector memory) { memory[1] = 12; memory[2] = 2; auto vm = IntCode(memory); std::cout << vm.get(0) << std::endl; } void solve_b(std::vector memory) { for(int x = 0; x < 99; x++){ for(int y = 0; y < 99; y++){ memory[1] = x; memory[2] = y; auto vm = IntCode(memory); if(vm.get(0) == 19690720) std::cout << x << ", " << y << " = " << (100 * x) + y << std::endl; } } } int main() { auto memory = read_input_file(); solve_a(memory); solve_b(memory); return 0; }