Last active
June 24, 2020 03:41
-
-
Save justecorruptio/ecaba65cce39e96f614a to your computer and use it in GitHub Desktop.
Tiny brainfuck interpreter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,os;M=[0]*30000;A=[] | |
p=k=x=0;S=open(sys.argv[1]).read() | |
while x<len(S):exec"""M[p]+=1 | |
M[p]-=1 M[p]=ord(os.read(0,1)or"\\0") | |
os.write(1,chr(M[p])) p-=p>0 p+=1 | |
k=A.append(x)if+M[p]else+1 x=A.pop()-1 | |
k+=1 0 k-=1 0""".split()['+-,.<>[][+]+' | |
.find(S[x]+'+'*(k>0))];M[p]&=255;x+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment