Brainf*ck

Make Brainf*ck interpreter.
Read Brainf*ck code as first line of stdin,
and read input characters as second line of stdin.

http://wikipedia.org/wiki/Brainfuck

Commands

> : inc pointer
< : dec pointer
+ : inc byte
- : dec byte
. : output byte
, : accept one byte
[ : if the byte at the data pointer is zero,
	jump it forward after the matching ] 
] : if the byte at the data pointer is nonzero,
	jump it back after the matching [

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hello, world!

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>+-.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hcjjm, umpjb!

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++-+++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hejjm, umpjb!

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++-+++..+++.>-.----+-------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hejjm,"umpjb#

IN

+++[>+++<-]>[>,+++.<-]
Brainf*ck

OUT

Eudlqi-fn

IN

+++[>+++<-]>[>,+-+.<-]
Brainf*ck

OUT

Csbjog+dl


Leave a comment

Parsed as Markdown

Login to leave a comment