def get_field(program: [int] = program) -> [[Object]]: machine = Machine(program) output = machine.run() field = [[]] for o in output: s = chr(o) if s == '\n': field.append([]) else: field[-1].append(Object(s)) return list(filter(bool, field))
def main(program=program) -> int: machine = Machine(program) result = machine.run() screen = {} i = 0 while i < len(result): x = result[i] y = result[i + 1] tile = Tile(result[i + 2]) screen[(x, y)] = tile i += 3 return sum(tile == Tile.BLOCK for tile in screen.values())