5
\$\begingroup\$

Write a Brainfuck interpreter that can interpret multiple Brainfuck programs embedded within the same source. The syntax is the same except that the instructions must be prefixxed with the number/ID of the targetted program. Example:

1st program

+++[->+<]

2nd program

+>++>+++.

Mashup

1+1+1+2+2>1[1-2+2+2>1>1+2+1<2+1]2+2.

What is required:

  • That it is theoretically able to interpret an unlimited number programs embedded within the same source.
  • That the instruction order does not matter.
  • That the code does not use features of a language that would natively solve this problem or natively interpret Brainfuck. Pretty much, don't cheat. I'll leave this to your discretion.

What is not:

  • Unlimited Brainfuck storage. Only a minimum of 1000 Brainfuck cells per is imposed.
  • It is not required that the input and output specify which bf program is doing the io. It'd be a cool feature tho, so if you do implement this you get -15 bytes.

You can do postfix if you want, just specify in that case. This is code-golf, so the smallest source in bytes (after the the -15 byte bonus) wins.

\$\endgroup\$
  • \$\begingroup\$ Could you be more specific as to how input/output is handled? \$\endgroup\$ – Shelvacu Aug 20 '14 at 1:12
  • \$\begingroup\$ shelvacu: It's the brainfuck io that I was referring to. \$\endgroup\$ – user2958652 Aug 20 '14 at 2:14
  • \$\begingroup\$ How will answers be scored? code-golf, popularity-context, or code-challenge? Based on the mention of byte-count bonuses, I'm guessing code-golf, but please tag it as such. \$\endgroup\$ – Bob Aug 20 '14 at 2:33
  • \$\begingroup\$ Are the ID's only numeric? \$\endgroup\$ – Οurous Aug 20 '14 at 6:10
  • 1
    \$\begingroup\$ I thought it was distinct enough, but fair enough. \$\endgroup\$ – user2958652 Aug 20 '14 at 12:01