One source, lots of Brainfuck

5

1

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.

user2958652

Posted 2014-08-20T00:41:59.353

Reputation: 99

Question was closed 2014-08-20T11:07:25.560

Could you be more specific as to how input/output is handled? – Shelvacu – 2014-08-20T01:12:31.950

shelvacu: It's the brainfuck io that I was referring to. – user2958652 – 2014-08-20T02:14:55.647

How will answers be scored? [tag:code-golf], [tag:popularity-context], or [tag:code-challenge]? Based on the mention of byte-count bonuses, I'm guessing [tag:code-golf], but please tag it as such. – Bob – 2014-08-20T02:33:20.730

Are the ID's only numeric? – Οurous – 2014-08-20T06:10:21.440

This is a relatively minor transformation of Interpret Brainfuck, and in my opinion is close enough to count as a duplicate.

– Peter Taylor – 2014-08-20T07:34:11.843

I agree with @PeterTaylor. In practice, you only need to split the input into the groups. The rest is a normal interpreter. Not sure this is really that much of a difference. – Ingo Bürk – 2014-08-20T09:41:54.523

1I thought it was distinct enough, but fair enough. – user2958652 – 2014-08-20T12:01:03.167

No answers