def get_map(self): print("Calculating map...") (limit_x_min, limit_x_max) = self.check_entire_line(self.min_y) print((limit_x_min, limit_x_max)) for y in range(self.min_y, self.max_y): i = 0 while limit_x_min + i < limit_x_max: beam = IntcodeMachine("data/archive/day19.txt") output = beam.add_input([limit_x_min + i, y]) if output[0] == 1: self.map[limit_x_min + i, y] = 1 limit_x_min += i break elif output[0] == 0: i += 1 i = 0 while limit_x_max + i < self.max_x: beam = IntcodeMachine("data/archive/day19.txt") output = beam.add_input([limit_x_max + i, y]) if output[0] == 1: self.map[limit_x_max + i, y] = 1 i += 1 elif output[0] == 0: if y <= 2: limit_x_max += 1 limit_x_max += i for x in range(limit_x_min, limit_x_max): self.map[x, y] = 1 break
def is_attracted(self, x, y): beam = IntcodeMachine("data/archive/day19.txt") output = beam.add_input([x, y]) if output[0] == 0: return False elif output[0] == 1: return True
def __init__(self): self.camera = IntcodeMachine("data/archive/day17.txt") self.coord = {} self.max_x = 0 self.max_y = 0 self.current_direction = "" self.robot_position = (0, 0) self.get_coordinates() self.directions = ["N", "E", "S", "W"]
def check_entire_line(self, y): limit_x_min = None limit_x_max = None for x in range(self.min_x, self.max_x): beam = IntcodeMachine("data/archive/day19.txt") output = beam.add_input([x, y]) if output[0] == 1 and limit_x_min is None: limit_x_min = x elif output[ 0] == 0 and limit_x_min is not None and limit_x_max is None: limit_x_max = x break return limit_x_min, limit_x_max
from day2 import IntcodeMachine if __name__ == "__main__": machine = IntcodeMachine("data/archive/day9.txt") print(machine.add_input([2]))
def create_amplifier(self, input) -> list[int]: self.amplifiers.append(IntcodeMachine("data/archive/day7.txt")) return self.amplifiers[-1].add_input(input)
def get_output(input) -> list[int]: machine = IntcodeMachine("data/archive/day7.txt") return machine.add_input(input)