3 ms·
I like doing codegolf in Python because it just feels so perverse. My golfed BF interpreter was way shorter than his :)
by cadr 15y ago
I like doing codegolf in Python because it just feels so perverse. My golfed BF interpreter was way shorter than his :)
- rwos 15y agoPython lends itself quite nicely to code-golfing, that's true. In fact I am constantly amazed of how terse Python code can be, despite the significant whitespace stuff. from os import* r='s=[0]*8**5' p=0 for c in read(0,9**9):r+='\n'+' '*p+dict(zip("><+-.,[","p+=1|p-=1|s[p]+=1|s[p]-=1|write(1,chr(s[p]))|s[p]=ord(read(0,1))|while s[p]:".split('|'))).get(c,'');p+=c in'[]'and 92-ord(c) exec r I know, it's a JIT compiler, not an interpreter, but still... :)
- cadr 15y agoMan, that's slick - similar how I did it, but even shorter :)