def part_1(): prog = intcode.parse_prog('17.in') camera = Camera(prog) camera.run_until_done() camera.parse_outputs() camera.sum_aligntment_parameters() list_scaffold = list(camera.scaffold) plt.scatter([list_scaffold[i][0] for i in range(len(list_scaffold))], [list_scaffold[i][1] for i in range(len(list_scaffold))]) plt.savefig('17_camera_out.pdf') print(camera.vaccuum_robot)
def part_2(): prog = intcode.parse_prog('17.in') prog[0] = 2 camera = Camera(prog) # From inspection.... x) camera.func_a = [76, 44, 49, 48, 44, 82, 44, 56, 44, 76, 44, 54, 44, 82, 44, 54, 10] camera.func_b = [76, 44, 56, 44, 76, 44, 56, 44, 82, 44, 56, 10] camera.func_c = [82, 44, 56, 44, 76, 44, 54, 44, 76, 44, 49, 48, 44, 76, 44, 49, 48, 10] camera.main_routine = [65, 44, 66, 44, 65, 44, 67, 44, 65, 44, 66, 44, 67, 44, 66, 44, 67, 44, 66, 10] camera.live_feed = [110, 10] camera.run_2()
#!/usr/bin/python3 import intcode prog = [1102, 34915192, 34915192, 7, 4, 7, 99, 0] prog = [ 109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99 ] computer = intcode.IntCode(prog) while not computer.done: computer.execute() print(computer.out) prog = intcode.parse_prog('in9.in') inputs = [2] computer = intcode.IntCode(prog, inputs) while not computer.done: computer.execute() print(computer.out)
if self.outputs[1] == 0: self.direction = (self.direction - 1) % 4 elif self.outputs[1] == 1: self.direction = (self.direction + 1) % 4 self.loc = tuple( (self.loc[i] + steps[self.direction][i] for i in range(2))) if self.loc in self.white: self.brain.inputs = [1 for i in range(100)] else: self.brain.inputs = [0 for i in range(100)] @property def panels_painted(self): painted = len(self.white) + len(self.black) return painted prog = intcode.parse_prog('11.in') robot = PaintingRobot(prog) robot.paint_loop() print(robot.panels_painted) # b list_white = list(robot.white) plt.scatter([list_white[i][0] for i in range(len(list_white))], [list_white[i][1] for i in range(len(list_white))]) plt.savefig('11b_out.pdf')