13
5
Your challenge is to turn input text to brain-flak code that will output the text.
Tutorial taken from here with permission here
Brain-Flak has two stacks, known as 'left' and 'right'. The active stack starts at left. If an empty stack is popped, it will return 0. That's it. No other variables. When the program starts, each command line argument is pushed on to the active stack.
The only valid characters in a Brain-Flak program are ()[]{}<>
, and they must always be balanced. There are two types of functions: Nilads and Monads. A nilad is a function that takes 0 arguments. Here are all of the nilads:
()
Evaluates to one.[]
Evaluates to the height of the current stack.{}
Pop the active stack. Evaluates to the popped value.<>
Toggle the active stack. Evaluates to zero.
These are concatenated together when they are evaluated. So if we had a '3' on top of the active stack, this snippet:
()(){}
would evaluate to 1 + 1 + active.pop()
which would evaluate to 5.
The monads take one argument, a chunk of Brain-Flak code. Here are all of the monads:
(n)
Push 'n' on the active stack.[n]
Evaluates to negative 'n'{foo}
While zero is not on the top of the stack, do foo.<foo>
Execute foo, but evaluate it as 0.
These functions will also return the value inside of them, so
(()()())
Will push 3 but
((()()()))
Will push 3 twice.
The {}
will evaluate to the sum of all runs. So if we had '3' and '4' on the top of the stack:
{{}}
would evaluate as 7.
When the program is done executing, each value left on the active stack is printed, with a newline between. Values on the other stack are ignored.
Rules
- You may assume that the Brain-Flak is being run with ascii out. (
-A
) - The brain-flak code must NOT require input
- All standard rules apply
- The code must run within 1 minute for any input up to 1024 bytes on TIO. (If no TIO output is available supply an interpreter and I will run it on my machine (my machine should be able to come close to TIO)).
- You must support arbitrary length input.
- You may take input from a file.
- Optimization for test cases is not allowed
- Deterministic output is required
- Programs don't need to be stack clean
Test cases (try your code on these, actual scoring texts will be released in 1-2 weeks after challenge is posted)
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
The meaning of brain-flak is to flak your brain with pain.
`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?
To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles
And by opposing end them. To die-to sleep,
No more; and by a sleep to say we die
<your brain-flak code here>
The fitness pacer test is a multi stage test. Avacado Avacado Avacadad Avacadad carrot.bat carrot.jar carrot.carrot Quack Quack Quack Quack Quack Quack Quack Quack Quack downgoat doawngoat down down gaot
This challenge came from a online program that turned text into brain-fuck. However brain-fuck has limitations and it is not nearly as cool as brain-flak. I really am looking forward to cool programs :) I am glad you took the time to read this and look forward to seeing your answer.
Winning
To win you must give the total length of the brain-flak code given by each of the test cases which will be released 1-2 weeks after the post date. The shortest total length wins.
NOTE!!!!!!:
This is not code-golf, length of your code will not effect your final score in any way. Making clean readable code is appreciated. Thanks!
Boxofsand – Christopher – 2018-03-07T18:48:44.760
Is
gaot
a typo? – Weijun Zhou – 2018-03-07T19:35:38.607@WeijunZhou no meme from TNB – Christopher – 2018-03-07T19:38:27.257
I see, thank you for clarification. – Weijun Zhou – 2018-03-07T19:38:56.470
4TNB memes are the dankest of memes. – Magic Octopus Urn – 2018-03-07T19:45:55.427
@MagicOctopusUrn as always – Christopher – 2018-03-07T19:49:42.273
05AB1E - 15 bytes - The worst possible score w/o actively trying to be bad, which (as it turns out) is almost as bad as trying to fail. – Magic Octopus Urn – 2018-03-08T18:28:17.883
1Wish I could double +1 this, instead I'll offer a bounty because I wanna know how this was supposed to be done. First answer that gets
<your brain-flak code here>
under 1000 is awarded the bounty. Which I cannot post for another day, whoops; didn't notice how new this was. – Magic Octopus Urn – 2018-03-08T20:59:35.817@magic sweet! That will bring fun answer's – Christopher – 2018-03-08T23:42:13.127
@MagicOctopusUrn status-complete
– HyperNeutrino – 2018-03-09T01:47:00.457@MagicOctopusUrn I think you've underestimated just how short that text could be golfed – Jo King – 2018-03-09T09:40:11.953
What is the range of characters that can be inputted? Printable ASCII? – Jo King – 2018-03-10T03:23:23.393
@JoKing anything that fits in 8 bits – Christopher – 2018-03-11T01:07:23.420
@JoKing copy error – Christopher – 2018-03-12T15:56:50.577
@Christopher If you aren't releasing the test cases yet, then you need to release their hashes, so you cannot change them. Otherwise, there's no way to know whether you design test cases after the fact to bias towards a certain answer. Though I don't think you would do that, I'm pretty sure it's policy that test cases should be fixed ahead of time if the score depends on them, and the proof of that is the hashes. – mbomb007 – 2018-03-14T13:29:13.650
1Also, if the range of input is not limited to printable ASCII, then you should include test cases that have every byte value, including NUL bytes. – mbomb007 – 2018-03-14T13:33:23.193
@mbomb I will give the hash soon (mobile) but I wouldn't bias them :P – Christopher – 2018-03-14T15:09:54.030
Just a reminder to release the test cases eventually – Jo King – 2018-03-26T06:35:54.123
Also, is the NUL byte a possible input? Because that will invalidate most solutions – Jo King – 2018-03-26T09:46:12.377
@joking I can't until Sunday because I ended up In Florida for a week – Christopher – 2018-03-27T18:31:21.623
2"Making clean, readable code is appreciated" hastily does challenge in 05AB1E – Magic Octopus Urn – 2018-04-02T18:09:26.513