From 61b4c2cc9c82b2b845090c4405ed3da9dae139f3 Mon Sep 17 00:00:00 2001 From: miggazElquez Date: Mon, 6 Jan 2020 23:53:18 +0100 Subject: [PATCH] correct bug in brainfuck.py (in function 'interpret') and add full debug support --- brainfuck.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/brainfuck.py b/brainfuck.py index 1f68df3..2c14468 100644 --- a/brainfuck.py +++ b/brainfuck.py @@ -61,7 +61,18 @@ def interpret(prog): if ar[ptr]: index = blocks.pop() continue + else: + blocks.pop() elif instr == '#': + try: + if prog[index+1] == '(': + index = index+2 + while prog[index] != ')': + print(prog[index],end='',flush=True) + index += 1 + print(' ',end='') + except IndexError: + pass print(ar, ptr, ar[ptr]) index += 1