Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by Kirill ( 5 years ago )
symbols = ['+', '-', '<', '>', '[', ']', '.', ',']

dirty_program = input()

clean_program = []

for i in range(len(dirty_program)):
    if dirty_program[i] in symbols:
        clean_program.append(dirty_program[i])


slovar = dict()

temp_list = []

for i in range(len(clean_program)):
    if clean_program[i] == '[':
        temp_list.append(i)
    elif clean_program[i] == ']':
        last_temp_list = temp_list.pop()
        slovar[last_temp_list] = i
        slovar[i] = last_temp_list


index_command = 0

lst = [0] * 30000

index = 15000

while index_command < len(clean_program):
    if clean_program[index_command] == '+':
        lst[index] += 1
        index_command += 1
    if clean_program[index_command] == '-':
        lst[index] -= 1
        index_command += 1
    if clean_program[index_command] == '>':
        index += 1
        index_command += 1
    if clean_program[index_command] == '<':
        index -= 1
        index_command += 1
    if clean_program[index_command] == ',':
        lst[index] = ord(input())
        index_command += 1
    if clean_program[index_command] == '.':
        print(chr(lst[index]), end='')
        index_command += 1
    if clean_program[index_command] == '[':
        if lst[index] == 0:
            index_command = slovar[index] + 1
    if clean_program[index_command] == ']':
        index_command = slovar[index]

 

Revise this Paste

Your Name: Code Language: