Skip to content

Instantly share code, notes, and snippets.

@rdebath rdebath/bf.rb
Created Sep 18, 2015

Embed
What would you like to do?
Brainfuck interpreter in ruby
eval 'm=Hash.new(p=0);'+ARGF.read.gsub(
/./,
'>' => 'p+=1;',
'<' => 'p-=1;',
'+' => 'm[p]+=1;',
'-' => 'm[p]-=1;',
'[' => '(',
']' => ')while((m[p]&=255)!=0);',
'.' => 'putc m[p];',
',' => 'm[p]=STDIN.getbyte if !STDIN.eof;')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.