7
1
This is inspired by the Brainf*** to tinyBF converter challenge.
Brainf**k (which will be henceforth referred to as BF) is a well-known estoric programming language, so I won't go over it too much here.
Nameless language is a binary-looking version of BF. See the linked page for more info.
Your challenge is to implement a golfed Nameless-to-BF converter. It should implement all of the commands except for 1100 (which isn't really possible to implement in BF) and 1010 (that isn't really possible, either). Any characters other than 1's and 0's should be ignored because they can be used for comments (after all, you wouldn't want an unreadable program, right? ;).
Here's a simple table of a Nameless -> BF mapping:
0000 -> >
0001 -> <
0010 -> +
0011 -> -
0100 -> .
0101 -> ,
0110 -> [
0111 -> ]
1011 -> [-]
1000 -> adds the base 10 value of the next command to the current memory cell (see below)
1001 -> subtracts the base 10 value of the next command from the current memory cell (see below)
NOTE: I accidentally flipped <
and >
. Thanks to @IlmariKaronen for pointing that out.
For 1000 and 1001, you can directly implement it in the translator. For instance, this:
1000 0010
could be written as:
++
The translator determined the value of the next command in advance and wrote it out.
Invalid sequences (e.g. 1111) and the presence of 1000/1001 at the end of the program are undefined; you don't have to handle them.
MAY THE GOLFING BEGIN!!!
Is it supposed to be binary? eg. 3 == 51 == 00110011 == --??? – Sylwester – 2015-04-10T01:38:11.190
OK, I looked it up.
+
in BF increments the current cell by 1 (so if the current cell has a value of 2,+
would make it 3.)1000 0100
does become++++++++
and1001 0100
becomes---------
. I'm also assuming1000
/1001
at the end of a line is also undefined. – ASCIIThenANSI – 2015-04-10T14:24:33.253@ASCIIThenANSI
0100
is 4, by the way, so1000 0100
is++++
. – mbomb007 – 2015-04-10T16:43:06.650@mbomb007 Oh, whoops. I meant
1000 0100
becomes++++.
. – ASCIIThenANSI – 2015-04-10T17:14:18.7001Note that you can, in fact, implement 1100 in BrainFuck. Translate 0000 to ">>", translate 0001 to "<<", prepend "+>" to the program, and translate 1100 to "<-[+<<-]+>", assuming you're targeting a BrainFuck interpreter where "<" at the start of the tape is illegal, or wraps back to the end of the tape. It's a whole lot harder otherwise. – Lymia Aluysia – 2015-04-10T22:33:26.963
@LymiaAluysia That makes sense, but it needs a compatible BF interpreter (maybe Beefit would work, since it pads the memory buffer...but it might also end up with 0 as the "random" value). – kirbyfan64sos – 2015-04-10T22:39:00.583
I've cleaned up some obsolete comments. Let me know if you want anything restored that didn't make it into the challenge (but I think everything did.) – Martin Ender – 2015-04-10T22:42:48.187
Ah... one question. Is excessive numbers also undefined? Such as in the program "11001" – Lymia Aluysia – 2015-04-10T23:43:56.047
@LymiaAluysia Yes. – kirbyfan64sos – 2015-04-11T01:10:14.410