Created
September 18, 2015 22:58
-
-
Save rdebath/3060affe89a739cf8624 to your computer and use it in GitHub Desktop.
Brainfuck interpreter in ruby
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
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