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!
<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. \$\endgroup\$