I would like to comment on one thing:
the level of inefficiency in this is staggering for a few reasons:
also about the while loop: I see the value "i" being incremented multiple places, even set to a different value. And at the end of the code, there is a stray "i += 1" outside the while loop that I assume it is supposed to be within. Otherwise it doesn't make any sense.
PROTIP: If there is even a slight chance there might be an error with values, always throw in random "print"'s everywhere. You can never have too many
EDIT: Also, why this?:
It seems to me like you are print out your code if no arguments where passed to the script
btw you can simplify the readlines() loop. The file already contains newlines so all you literally need to do is print(f.read())
EDIT: Okay seriously, to answer your actual call for help (please don't call it a dare, that's just desperate), Your code is trying to delete stack[-1] which obviously doesn't exist. replace the deletion of stack with this code:
The other error that is raised has to do with the way you save the stack. It doesn't work. You need to figure out a different way of remembering each corresponding square parentheses. Last known index (as far as I can tell from the code) cannot possibly be a reasonable way of determining the correct corresponding one.
Code:
tape = list(range(256))
for i in tape:
tape[i] = 0;
- There are 2 loops
- Creating an array from an iterator, then resetting all the values in it
- 3 lines
- What is this semicolon even doing there? This isn't java
Code:
tape = [0] * 256
also about the while loop: I see the value "i" being incremented multiple places, even set to a different value. And at the end of the code, there is a stray "i += 1" outside the while loop that I assume it is supposed to be within. Otherwise it doesn't make any sense.
PROTIP: If there is even a slight chance there might be an error with values, always throw in random "print"'s everywhere. You can never have too many
EDIT: Also, why this?:
Code:
if len(sys.argv) == 1:
with open('bfsint.py', 'r+') as f:
for l in f.readlines():
print(l)
quit()
btw you can simplify the readlines() loop. The file already contains newlines so all you literally need to do is print(f.read())
EDIT: Okay seriously, to answer your actual call for help (please don't call it a dare, that's just desperate), Your code is trying to delete stack[-1] which obviously doesn't exist. replace the deletion of stack with this code:
Code:
if cval == 0:
if len(stack) >= 1:
del stack[len(stack)-1]
continue
The other error that is raised has to do with the way you save the stack. It doesn't work. You need to figure out a different way of remembering each corresponding square parentheses. Last known index (as far as I can tell from the code) cannot possibly be a reasonable way of determining the correct corresponding one.
<-- The actual Minecraft server host