Exemple #1
0
def travel_ship():
    output = []
    computer = IntCode(state, [])
    while not computer.is_completed():
        try:
            out = computer.execute(input_func)
            if out == 10:
                print(''.join(list(map(chr, output))))
                output = []
            else:
                output += [out]
        except IndexError:
            break
Exemple #2
0
    return 0 <= row < len(view) and 0 <= col < len(view[0])


def list_join(l, sep):
    new_list = []
    for i in l:
        new_list += [i, sep]
    return new_list[:-1]


# map generation
view = []
line = []
start = None
computer = IntCode(state, [])
while not computer.is_completed():
    try:
        out = computer.execute(part1_input)
        if out == 10:
            view.append(line)
            line = []
        else:
            line.append(chr(out))
        if chr(out) in "^<v>":
            direction = ['^', '<', 'v', '>'].index(chr(out))
            start = (len(view), len(line) - 1)
    except IndexError:
        pass
view.pop()  #accounts for extra newline at end

for row in view: