1105, 1, 415, 21202, -4, -1, -4, 22201, -4, -3, -4, 22202, -3, -2, -2,
    22202, -2, -4, -4, 22202, -3, -2, -3, 21202, -4, -1, -2, 22201, -3, -2, 1,
    21201, 1, 0, -4, 109, -5, 2106, 0, 0
]

outputs = []
image = []
start = 700
up_to = 1200
for y in range(start, up_to):
    print(y)
    image += [[]]
    can_stop = False
    for x in range(start, up_to + 100):
        _, one_output = intcode(memory,
                                inputs=[x, y],
                                output_vars=False,
                                prints=False)
        if one_output[0] == 0:
            symbol = '.'
            will_Stop = True
        else:
            can_stop = True
            will_Stop = False
            symbol = '#'
        if can_stop and will_Stop:
            for c in range(len(image[-1]), up_to + 100):
                image[-1] += '.'
            break
        image[-1] += [symbol]

print('')
Exemplo n.º 2
0
print('10')
list_inputs += [10]
for item in fun_B:
    print(str(ord(item)) + ',', end='')
    list_inputs += [ord(item)]
print('10')
list_inputs += [10]
for item in fun_C:
    print(str(ord(item)) + ',', end='')
    list_inputs += [ord(item)]
print('10')
list_inputs += [10]


while True:
    memory, output = intcode(memory, prints=False, inputs=list_inputs)

    if memory[0] == 1:
        memory[0] = 2

    scaffold_map = [[]]
    for item in output:
        try:
            print(chr(item), end='')
            if chr(item) != '\n':
                scaffold_map[-1] += [chr(item)]
            else:
                scaffold_map += [[]]
        except ValueError:
            print(f'End! -> {item}')
Exemplo n.º 3
0
from IntCode import intcode_day2 as intcode

# Puzzle Inputs
Input_Ints = [1, 12, 2, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 1, 13, 19, 1, 9, 19, 23, 1, 6, 23, 27, 2, 27, 9, 31, 2, 6, 31, 35, 1, 5, 35, 39, 1, 10, 39, 43, 1, 43, 13, 47, 1, 47, 9, 51, 1, 51, 9, 55, 1, 55, 9, 59, 2, 9, 59, 63, 2, 9, 63, 67, 1, 5, 67, 71, 2, 13, 71, 75, 1, 6, 75, 79, 1, 10, 79, 83, 2, 6, 83, 87, 1, 87, 5, 91, 1, 91, 9, 95, 1, 95, 10, 99, 2, 9, 99, 103, 1, 5, 103, 107, 1, 5, 107, 111, 2, 111, 10, 115, 1, 6, 115, 119, 2, 10, 119, 123, 1, 6, 123, 127, 1, 127, 5, 131, 2, 9, 131, 135, 1, 5, 135, 139, 1, 139, 10, 143, 1, 143, 2, 147, 1, 147, 5, 0, 99, 2, 0, 14, 0]
Objective = 19690720

noun = -1
verb = -1
while True:
    noun += 1
    while True:
        verb += 1
        Input_Ints[1] = noun
        Input_Ints[2] = verb
        try:
            output = intcode(Input_Ints)[0]
        except IndexError:
            output = 0
        if verb == 99:
            verb = 0
            break
        if output == Objective:
            break
    if noun == 99:
        break
    if output == Objective:
        break
print(noun, verb, '\n\n' + str(100*noun+verb))
    -3, 1, 2, 21102, 1, 1, 3, 21101, 0, 1949, 0, 1106, 0, 1954, 109, -5, 2106,
    0, 0, 109, 6, 21207, -4, 1, -1, 1206, -1, 1977, 22207, -5, -3, -1, 1206,
    -1, 1977, 22101, 0, -5, -5, 1105, 1, 2045, 21201, -5, 0, 1, 21201, -4, -1,
    2, 21202, -3, 2, 3, 21102, 1996, 1, 0, 1106, 0, 1954, 21201, 1, 0, -5,
    21101, 0, 1, -2, 22207, -5, -3, -1, 1206, -1, 2015, 21102, 1, 0, -2, 22202,
    -3, -2, -3, 22107, 0, -4, -1, 1206, -1, 2037, 21202, -2, 1, 1, 21101, 0,
    2037, 0, 105, 1, 1912, 21202, -3, -1, -3, 22201, -5, -3, -5, 109, -6, 2105,
    1, 0
]

program_str = '''OR A T
AND B T
AND C T
NOT T J
AND D J
WALK

'''.upper()

program_ASCII = []
for item in program_str:
    program_ASCII += [ord(item)]

_, output = intcode(memory, program_ASCII)

for item in output:
    try:
        print(chr(item), end='')
    except ValueError:
        print(item)
Exemplo n.º 5
0
# Initial values for the panels and robot
total_list, order_list = [], []
white_list, black_list = [[0, 0]], []
coords = [0, 0]
directions = ['up', 'right', 'down', 'left']
looking = 0

while True:
    # See the color of the panel
    if white_list.__contains__(coords):
        color = [1]
    else:
        color = [0]
    # Get the robot's action
    memory, outputs, com_pos, rel_bas = intcode(memory, color, com_pos,
                                                rel_bas)

    # Evaluate the outputs
    if outputs.__contains__(-1):
        break
    else:
        # Paint the tile
        if outputs[0] == 0:
            if coords in white_list:
                white_list.remove(coords[:])
            if coords not in black_list:
                black_list += [coords[:]]
        elif outputs[0] == 1:
            if coords in black_list:
                black_list.remove(coords[:])
            if coords not in white_list:
    elif int_input == 4:
        move = [1, 0]
    else:
        move = [0, 0]

    if _key == 't' or _key == 'g' or _key == 'f' or _key == 'h':
        while True:
            new_moves += [int_input]
            print(new_moves)

            space[max_y - pos[1]][pos[0]] = below_droid

            pos[0] += move[0]
            pos[1] += move[1]

            memory, output, com_pos, rel_bas = intcode(memory, inputs=[int_input], com_pos=com_pos, rel_bas=rel_bas,
                                                       output_vars=True)

            if output[0] == 0:
                space[max_y - pos[1]][pos[0]] = 'W'
                pos[0] -= move[0]
                pos[1] -= move[1]
            elif output[0] == 1:
                if not all_pos.__contains__(pos):
                    distance_from_O += 1
                    all_pos += [pos[:]]
                else:
                    distance_from_O -= 1
                    all_pos.pop(-1)
                if space[max_y - pos[1]][pos[0]] != 'B':
                    space[max_y - pos[1]][pos[0]] = '.'
            elif output[0] == 2:
    1, 46, 1, 9, 1, 46, 1, 9, 1, 46, 1, 9, 1, 46, 1, 9, 1, 46, 1, 9, 1, 46, 1,
    9, 1, 44, 13, 44, 1, 1, 1, 54, 1, 1, 1, 54, 1, 1, 1, 54, 1, 1, 9, 46, 1, 9,
    1, 46, 1, 9, 1, 46, 1, 9, 1, 46, 1, 9, 1, 11, 13, 22, 1, 9, 1, 11, 1, 11,
    1, 22, 1, 9, 1, 11, 1, 9, 11, 14, 1, 9, 1, 11, 1, 9, 1, 1, 1, 7, 1, 14, 9,
    1, 1, 11, 1, 9, 1, 1, 1, 7, 1, 22, 1, 1, 1, 11, 1, 9, 1, 1, 1, 7, 1, 22, 1,
    1, 1, 11, 1, 9, 1, 1, 1, 7, 1, 22, 1, 1, 1, 11, 1, 9, 1, 1, 1, 7, 1, 22, 1,
    1, 13, 9, 1, 1, 1, 7, 1, 22, 1, 23, 1, 1, 1, 7, 1, 14, 13, 19, 13, 12, 1,
    7, 1, 25, 1, 7, 1, 1, 1, 12, 1, 7, 1, 25, 9, 1, 1, 12, 1, 7, 1, 35, 1, 12,
    1, 7, 1, 35, 1, 12, 1, 7, 1, 35, 1, 8, 13, 35, 1, 8, 1, 3, 1, 43, 14, 43,
    2, 7, 1, 47, 2, 7, 1, 37, 9, 1, 2, 7, 1, 37, 1, 7, 1, 1, 2, 7, 1, 35, 14,
    7, 1, 35, 1, 1, 1, 7, 1, 2, 1, 7, 1, 35, 1, 1, 1, 7, 1, 2, 1, 7, 1, 35, 1,
    1, 1, 7, 1, 2, 1, 7, 1, 35, 1, 1, 1, 7, 1, 2, 1, 7, 1, 35, 1, 1, 1, 7, 1,
    2, 9, 35, 1, 1, 1, 7, 1, 46, 1, 1, 1, 7, 1, 46, 11, 48, 1, 44, 13, 10
]

memory, output = intcode(memory, prints=False)

scaffold_map = [[]]
for item in output:
    try:
        print(chr(item), end='')
        if chr(item) != '\n':
            scaffold_map[-1] += [chr(item)]
        else:
            scaffold_map += [[]]
    except ValueError:
        print(f'End! -> {item}')

for c in range(0, 2):
    scaffold_map.remove([])
    1001, 64, 1, 64, 1106, 0, 545, 1002, 64, 2, 64, 109, 12, 21102, 43, 1, -8,
    1008, 1010, 43, 63, 1005, 63, 571, 4, 551, 1001, 64, 1, 64, 1106, 0, 571,
    1002, 64, 2, 64, 109, -1, 1207, -8, 27, 63, 1005, 63, 593, 4, 577, 1001,
    64, 1, 64, 1106, 0, 593, 1002, 64, 2, 64, 109, -7, 21101, 44, 0, 8, 1008,
    1018, 42, 63, 1005, 63, 617, 1001, 64, 1, 64, 1105, 1, 619, 4, 599, 1002,
    64, 2, 64, 109, -4, 1208, -1, 39, 63, 1005, 63, 639, 1001, 64, 1, 64, 1105,
    1, 641, 4, 625, 1002, 64, 2, 64, 109, 13, 2105, 1, 5, 4, 647, 1106, 0, 659,
    1001, 64, 1, 64, 1002, 64, 2, 64, 109, 4, 1206, -3, 673, 4, 665, 1106, 0,
    677, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -22, 21108, 45, 45, 10, 1005,
    1011, 699, 4, 683, 1001, 64, 1, 64, 1105, 1, 699, 1002, 64, 2, 64, 109, 29,
    2105, 1, -7, 1001, 64, 1, 64, 1105, 1, 717, 4, 705, 1002, 64, 2, 64, 109,
    -19, 21107, 46, 47, 5, 1005, 1016, 739, 4, 723, 1001, 64, 1, 64, 1106, 0,
    739, 1002, 64, 2, 64, 109, -8, 2102, 1, 2, 63, 1008, 63, 33, 63, 1005, 63,
    763, 1001, 64, 1, 64, 1106, 0, 765, 4, 745, 1002, 64, 2, 64, 109, 1, 1201,
    -2, 0, 63, 1008, 63, 25, 63, 1005, 63, 791, 4, 771, 1001, 64, 1, 64, 1105,
    1, 791, 1002, 64, 2, 64, 109, 16, 1205, 0, 803, 1105, 1, 809, 4, 797, 1001,
    64, 1, 64, 1002, 64, 2, 64, 109, -8, 1205, 9, 827, 4, 815, 1001, 64, 1, 64,
    1106, 0, 827, 1002, 64, 2, 64, 109, -4, 2102, 1, -3, 63, 1008, 63, 36, 63,
    1005, 63, 853, 4, 833, 1001, 64, 1, 64, 1106, 0, 853, 1002, 64, 2, 64, 109,
    17, 21102, 47, 1, -6, 1008, 1019, 50, 63, 1005, 63, 877, 1001, 64, 1, 64,
    1105, 1, 879, 4, 859, 1002, 64, 2, 64, 109, -29, 2107, 22, 5, 63, 1005, 63,
    897, 4, 885, 1106, 0, 901, 1001, 64, 1, 64, 4, 64, 99, 21102, 27, 1, 1,
    21101, 0, 915, 0, 1106, 0, 922, 21201, 1, 25338, 1, 204, 1, 99, 109, 3,
    1207, -2, 3, 63, 1005, 63, 964, 21201, -2, -1, 1, 21101, 942, 0, 0, 1105,
    1, 922, 22102, 1, 1, -1, 21201, -2, -3, 1, 21102, 957, 1, 0, 1106, 0, 922,
    22201, 1, -1, -2, 1105, 1, 968, 21202, -2, 1, -2, 109, -3, 2106, 0, 0
]

# Input 2
intcode(puzzle_memory)
    9, 29, 3, 89, 36, 19, 66, 66, 12, 35, 46, 14, 24, 56, 87, 71, 16, 94, 27,
    88, 7, 18, 22, 30, 52, 90, 42, 18, 39, 45, 68, 54, 50, 74, 27, 42, 1, 24,
    30, 5, 60, 24, 20, 91, 33, 57, 55, 60, 6, 58, 52, 27, 13, 85, 98, 27, 8,
    67, 66, 33, 16, 33, 15, 88, 73, 75, 51, 90, 90, 27, 88, 32, 60, 20, 34, 86,
    67, 38, 83, 76, 19, 67, 36, 63, 50, 56, 41, 37, 40, 37, 34, 75, 52, 82, 60,
    25, 57, 62, 82, 34, 53, 82, 1, 49, 9, 24, 35, 22, 86, 60, 14, 75, 63, 14,
    5, 37, 75, 96, 21, 64, 39, 74, 7, 59, 8, 42, 96, 7, 14, 43, 76, 62, 70, 16,
    30, 3, 36, 62, 77, 68, 95, 60, 19, 45, 7, 62, 14, 24, 30, 91, 91, 26, 11,
    73, 2, 74, 8, 60, 17, 96, 74, 5, 88, 72, 85, 41, 57, 47, 22, 42, 4, 52, 42,
    48, 73, 52, 43, 87, 49, 29, 49, 24, 97, 76, 30, 34, 75, 24, 58, 23, 54, 4,
    73, 56, 84, 11, 77, 60, 59, 78, 5, 5, 79, 45, 94, 47, 49, 84, 38, 54, 48,
    86, 76, 27, 23, 42, 73, 42, 2, 64, 33, 63, 70, 1, 86, 5, 1, 77, 43, 16, 34,
    61, 44, 28, 76, 34, 76, 16, 89, 56, 72, 12, 28, 37, 38, 5, 23, 13, 49,
    899068
]

memory, outputs = intcode(arcade_program)

tiles = []
for tile in range(0, int(len(outputs) / 3)):
    tiles += [[
        outputs[3 * tile], outputs[3 * tile + 1], outputs[3 * tile + 2]
    ]]

block_tiles = 0
for tile in tiles:
    if tile[2] == 2:
        block_tiles += 1

print(block_tiles)