223, 223, 1006, 224, 329, 1001, 223, 1, 223, 1008, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 344, 1001, 223, 1, 223, 7, 226, 677, 224, 102, 2, 223, 223, 1005, 224, 359, 1001, 223, 1, 223, 8, 226, 226, 224, 102, 2, 223, 223, 1006, 224, 374, 1001, 223, 1, 223, 1007, 226, 226, 224, 102, 2, 223, 223, 1006, 224, 389, 101, 1, 223, 223, 8, 677, 226, 224, 1002, 223, 2, 223, 1005, 224, 404, 101, 1, 223, 223, 1108, 677, 226, 224, 102, 2, 223, 223, 1006, 224, 419, 1001, 223, 1, 223, 1108, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 434, 101, 1, 223, 223, 1108, 677, 677, 224, 1002, 223, 2, 223, 1005, 224, 449, 101, 1, 223, 223, 1008, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 464, 101, 1, 223, 223, 7, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 479, 101, 1, 223, 223, 108, 677, 677, 224, 1002, 223, 2, 223, 1005, 224, 494, 101, 1, 223, 223, 107, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 509, 101, 1, 223, 223, 107, 226, 226, 224, 102, 2, 223, 223, 1006, 224, 524, 1001, 223, 1, 223, 1107, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 539, 101, 1, 223, 223, 1008, 226, 226, 224, 102, 2, 223, 223, 1006, 224, 554, 1001, 223, 1, 223, 8, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 569, 101, 1, 223, 223, 1007, 677, 677, 224, 102, 2, 223, 223, 1005, 224, 584, 1001, 223, 1, 223, 1107, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 599, 101, 1, 223, 223, 7, 226, 226, 224, 1002, 223, 2, 223, 1005, 224, 614, 101, 1, 223, 223, 108, 677, 226, 224, 1002, 223, 2, 223, 1005, 224, 629, 1001, 223, 1, 223, 108, 226, 226, 224, 1002, 223, 2, 223, 1005, 224, 644, 101, 1, 223, 223, 1007, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 659, 101, 1, 223, 223, 1107, 226, 226, 224, 102, 2, 223, 223, 1005, 224, 674, 1001, 223, 1, 223, 4, 223, 99, 226 ] input = [5] import intcode intcode = intcode.IntCodeRunner(memory) print(intcode.run(input)[-1])
551, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 9, 1206, -3, 581, 4, 569, 1001, 64, 1, 64, 1106, 0, 581, 1002, 64, 2, 64, 109, -8, 1201, -9, 0, 63, 1008, 63, 23, 63, 1005, 63, 605, 1001, 64, 1, 64, 1106, 0, 607, 4, 587, 1002, 64, 2, 64, 109, 21, 2106, 0, -9, 1106, 0, 625, 4, 613, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -35, 2108, 31, 8, 63, 1005, 63, 647, 4, 631, 1001, 64, 1, 64, 1105, 1, 647, 1002, 64, 2, 64, 109, 2, 1202, 0, 1, 63, 1008, 63, 30, 63, 1005, 63, 667, 1105, 1, 673, 4, 653, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 17, 21108, 43, 43, -4, 1005, 1016, 691, 4, 679, 1106, 0, 695, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -14, 1208, -1, 30, 63, 1005, 63, 711, 1106, 0, 717, 4, 701, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 6, 21101, 44, 0, -1, 1008, 1011, 44, 63, 1005, 63, 739, 4, 723, 1105, 1, 743, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -15, 2108, 30, 8, 63, 1005, 63, 759, 1106, 0, 765, 4, 749, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 27, 2105, 1, 0, 4, 771, 1001, 64, 1, 64, 1105, 1, 783, 1002, 64, 2, 64, 109, -9, 1206, 6, 795, 1105, 1, 801, 4, 789, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 4, 21102, 45, 1, -7, 1008, 1012, 45, 63, 1005, 63, 823, 4, 807, 1105, 1, 827, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -14, 21102, 46, 1, 5, 1008, 1010, 43, 63, 1005, 63, 851, 1001, 64, 1, 64, 1105, 1, 853, 4, 833, 1002, 64, 2, 64, 109, -1, 2101, 0, 1, 63, 1008, 63, 25, 63, 1005, 63, 873, 1105, 1, 879, 4, 859, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 9, 21107, 47, 48, -3, 1005, 1010, 897, 4, 885, 1105, 1, 901, 1001, 64, 1, 64, 4, 64, 99, 21101, 0, 27, 1, 21101, 915, 0, 0, 1106, 0, 922, 21201, 1, 57526, 1, 204, 1, 99, 109, 3, 1207, -2, 3, 63, 1005, 63, 964, 21201, -2, -1, 1, 21101, 942, 0, 0, 1106, 0, 922, 21201, 1, 0, -1, 21201, -2, -3, 1, 21101, 957, 0, 0, 1106, 0, 922, 22201, 1, -1, -2, 1105, 1, 968, 21202, -2, 1, -2, 109, -3, 2106, 0, 0 ] intcode = intcode.IntCodeRunner(code) intcode.resume([2]) print(intcode.output)
3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 101, 1, 9, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 99, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 3, 9, 102, 2, 9, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 99, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1001, 9, 1, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 3, 9, 101, 1, 9, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1002, 9, 2, 9, 4, 9, 3, 9, 1001, 9, 1, 9, 4, 9, 3, 9, 101, 2, 9, 9, 4, 9, 99 ] max_out = 0 amps = [] for i in range(0, 5): amps.append(intcode.IntCodeRunner(code)) for phase in permutations_of([9, 7, 8, 5, 6]): for a in amps: a.reset() amps[4].output.append(0) for t in range(0, 200): current_amp = t % 5 last_amp = (t - 1) % 5 if t < 5: input = [phase[current_amp], amps[last_amp].output[-1]] else: input = [amps[last_amp].output[-1]]