from field import coord filename = "15day-input.txt" output_file = "output.txt" if os.path.exists(output_file): os.remove(output_file) if len(sys.argv) > 1: filename = sys.argv[1] comp = IntComp(filename) halls = Field() status = Status.INPUT_REQUIRED pos = coord(0, 0) move = coord(0, 0) mapping = {-1: '#', 0: '.', 65537: '@'} def set_dist(loc): dist = 2**16 adjacent = [] adjacent.append(halls.get_val(loc.x, loc.y + 1)) adjacent.append(halls.get_val(loc.x, loc.y - 1)) adjacent.append(halls.get_val(loc.x + 1, loc.y)) adjacent.append(halls.get_val(loc.x - 1, loc.y))
from field import coord filename = "11day-input.txt" output_file = "output.txt" if os.path.exists(output_file): os.remove(output_file) if len(sys.argv) > 1: filename = sys.argv[1] comp = IntComp(filename) hull = Field() status = Status.INPUT_REQUIRED pos = coord(0, 0) rot = 0 #0 = up, increasing clockwise count = set() # Day 11.2 hull.set_val(1, pos) while status == Status.INPUT_REQUIRED: paint = hull.get_val(pos) outs = comp.execute_tape(paint) status = outs[0] turn = outs[1][1] hull.set_val(outs[1][0], pos)
return 4 elif rot == 2: return 3 elif rot == 3: return 1 elif rot == 4: return 2 else: print(f"ERROR: Bad Rotation {rot}") comp = IntComp(filename) halls = Field() status = Status.INPUT_REQUIRED pos = coord(0,0) move = coord(0,0) oxy_pos = coord(0,0) mapping = {-1:'#', 0:'.', -2:'@', -3:'O'} oxy_found = False oxy_dist = 0 max_dist = 0 num_attempts = 0 right_hand = 1 iteration = 1 halls.set_val(-2, pos)
#! /bin/usr/env python3 import sys import os from intcomp import IntComp from intcomp import Status from field import Field from field import coord filename = "17day-input.txt" output_file = "output.txt" if os.path.exists(output_file): os.remove(output_file) if len(sys.argv) > 1: filename = sys.argv[1] comp = IntComp(filename) halls = Field() status = Status.INPUT_REQUIRED pos = coord(0, 0) move = coord(0, 0)