from common import day fh = open(f"input/{day()}") X = 1 cycle = 0 r = 0 row = [] while True: cycle += 1 pos = (cycle - 1) % 40 if pos == 0: print("".join(row)) row = [] if pos in (X-1, X, X+1): row.append("#") else: row.append(".") try: line = next(fh) except StopIteration: print(r) break line = line.rstrip() match line.split(): case ["noop"]: continue case ["addx", val]: val = int(val) cycle += 1 pos = (cycle - 1) % 40 if pos == 0: print("".join(row)) row = [] if pos in (X-1, X, X+1): row.append("#") else: row.append(".") X += val