Nie wiedziałem gdzie dodać ten post dlatego w razie czego prosiłbym o jego przeniesienie w odpowiednie miejsce.
Chodzi o to, że nie proszę stricte o ocenę kodu. Moje pytanie odnosi się do definiowania większej ilości funkcji. Czy w tak krótkim programie opłacalnym jest pisanie większej ilości funkcji czy lepiej zostawić kod w jednej?`
commands = input()
def execute(commands):
bf_array, cell_pointer, bf_code_pointer = [0], 0, 0
bf_code = list(commands)
while bf_code_pointer < len(bf_code):
if bf_code[bf_code_pointer] == '>':
bf_array.append(0)
cell_pointer += 1
if bf_code[bf_code_pointer] == '<':
cell_pointer -= 1
if bf_code[bf_code_pointer] == '+':
bf_array[cell_pointer] += 1
if bf_code[bf_code_pointer] == '-':
bf_array[cell_pointer] -= 1
if bf_code[bf_code_pointer] == '.': print(chr(bf_array[cell_pointer]))
if bf_code[bf_code_pointer] == ',': bf_array[cell_pointer] = ord(input())
if bf_code[bf_code_pointer] == '[' and bf_array[cell_pointer] == 0:
while bf_code[bf_code_pointer] != ']':
bf_code_pointer += 1
if bf_code[bf_code_pointer] == ']' and bf_array[cell_pointer] != 0:
while bf_code[bf_code_pointer] != '[':
bf_code_pointer -= 1
bf_code_pointer += 1
execute(commands)