I Dare you to fix this - Printable Version +- Forums - Open Redstone Engineers (https://forum.openredstone.org) +-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html) +--- Forum: Programming (https://forum.openredstone.org/forum-8.html) +--- Thread: I Dare you to fix this (/thread-9684.html) |
I Dare you to fix this - TheCrimulo - 03-30-2016 https://gist.github.com/anonymous/b9d2fbd692cc1be814a28f0288a22a24 bfsint.py: Code: #!/usr/bin/python3 test.bfs: Code: $2*.[>+++[>++<-]<-] This is a bf-based language. Bash: Code: thecrimulo@ubuntu:~/Escritorio/subatom/bf#$ python3 bfsint.py hworld.bfs Meny ppl tried to fix it, no one could RE: I Dare you to fix this - PabloDons - 03-30-2016 I would like to comment on one thing: Code: tape = list(range(256))
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: 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: 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. RE: I Dare you to fix this - Apuly - 03-30-2016 1: Why are you fixing the length of a list? If you want to use that, use an array. 2: pointer_pos is a terrible name for the index, because 1: it's an index, 2: python doesn't have pointers, and 3: pointer_pos sounds like a pointer pointer to me. 3: Code: asciival = str(chr(tape[index])) 4: Code: f = i + 1 Code: assign = evr[i+1: evr.find("*", beg=i)] |