r/codegolf • u/binarycat64 • Oct 16 '20
BrainF*** interpreter in 248 bytes of Ruby
t={};s=ARGV[t.default=p=w=0];m={"+"=>"z+=1","-"=>"z-=1","."=>"puts z.chr",","=>"z=STDIN.getc.ord","<"=>"p-=1",">"=>"p+=1","]"=>"z==0||w-=Z'['","["=>"z==0&&w+=Z']'"};until w==s.length;eval m[s[w]].gsub(/Z/,"1until s[w]==").gsub(/z/,"t[p]");w+=1;end
Unfortunatly dosn't do nested brackets (I have enough trouble doing that normally).
16
Upvotes
5
u/madsohm Oct 17 '20
Here’s mine in 234 bytes