#include #include #include #include #include "../../lib/intcode.h" #define EXPECTED_OUTPUT 19690720 int main() { ic_load_rom_from_input(); IC *c = ic_new_computer(); ic_poke(c, 1, 12); ic_poke(c, 2, 2); ic_run(c); printf("Part 1: %d\n", ic_peek(c, 0)); int noun, verb; for (noun = 0; noun < 100; noun++) { for (verb = 0; verb < 100; verb++) { ic_reset(c); ic_poke(c, 1, noun); ic_poke(c, 2, verb); ic_run(c); if (ic_peek(c, 0) == EXPECTED_OUTPUT) goto done; } } done: printf("Part 2: %d\n", noun * 100 + verb); aoc_free(); return 0; }