예제 #1
0
from day02.common import get_input
from day05.common import *

if __name__ == '__main__':
    l = get_input('input.txt')
    Computer([1], l).run_program()
예제 #2
0
def get_dimensions(tiles_dict):
    min_x, min_y, max_x, max_y = sys.maxsize, sys.maxsize, -sys.maxsize, -sys.maxsize
    for key in tiles_dict.keys():
        x, y = key
        min_x = min(x, min_x)
        min_y = min(y, min_y)
        max_x = max(x, max_x)
        max_y = max(y, max_y)
    dimensions = (max_x - min_x) + 1, (max_y - min_y) + 1
    return dimensions, min_x, min_y


def dict_to_array(tiles_dict):
    dimensions, min_x, min_y = get_dimensions(tiles_dict)
    array_2d = zeros(dimensions)
    for key, value in tiles_dict.items():
        x, y = key
        x -= min_x
        y -= min_y
        array_2d[y][x] = value
    return array_2d


if __name__ == '__main__':
    program = get_input('input.txt')
    painted_tiles = run_robot(program, 1)
    image = dict_to_array(painted_tiles)
    plt.imshow(image)
    plt.show()