19
1
Cubically is too tedious to manually write any code in. Your challenge is to translate ASCII text into Cubically source code.
Cubically
This is just a quick run-down of Cubically; the repository has a more complete guide and details.
Cubically is an esolang I wrote a while ago, designed to be painful to use. It contains two pieces of memory, a 3x3x3 Rubik's Cube and a register called the "notepad".
Memory
The internal Rubik's Cube is initialized like this:
000
000 top face
000
111222333444 left, front, right, and back faces, respectively
111222333444
111222333444
555
555 down face
555
After performing a clockwise 90° turn on the right face, the memory cube would look like this:
002
002
002
111225333044
111225333044
111225333044
554
554
554
Commands
A non-integer character sets the default command. For each integer before the default command is set once again, the command is performed with that integer. For example, x524y312
would perform command x
with 5, then with 2, then with 4, then perform command y
with 3, then with 1, then with 2.
The integers that commands use represent face indexes. So x0
would perform x
on the UP (0-indexed) face. x1
would perform x
on the LEFT (1-indexed) face, and so on.
Performing any command with 6
will perform that command on the notepad value. Performing any command with any integer over 6 will result in an error.
Here are some example commands:
R1
- turn the RIGHT face clockwise 90° so the internal cube will look like the second example aboveR11
- turn the RIGHT face clockwise 90° twice, identical toR2
+0
- add all values of the UP face to the notepad+000
- add all values of the UP face to the notepad three times@6
- print the nonexistent 6th-indexed face (memory) as a character%4
- print the sum of all values on the BACK face as an integer
A complete list of commands and syntax is available at the repository.
Challenge
You will take ASCII text as input and print a Cubically program as output.
Examples (stolen from here and here):
Input -> Output
Hello, World! -> +53@6+1F2L2+0@6L2F2U3R3F1L1+2@66L3F3R1U1B3+0@6:4U1R1+00@6-000@6*0-4+000@6-00@6+2-000000@6-5+4000@6-00@6/0+00@6:0+0/0+00@6
1$2$3$4$5$6$7$8$9$10$ -> B1+2/2%6@4+00/0%6@4+00/1%6@4+21/1%6@4+30/0%6@4+22/1%6@4+22/1%6@4+40/1%6@4+52/1%6@4+42/1%6@4
Rules
- Your program may not contain a dictionary containing the translations for the 100 testcases.
- Your program must finish in less than 180 seconds (no brute-force programs that take weeks).
- Your program must output valid Cubically code that finishes in less than 180 seconds.
- Your program will take input via standard input, unless you want to mess with the test driver.
- Your program must output Cubically code that produces nothing but your program's input when run. ಠ_ಠ
Scoring
You will test your program with 100 pseudorandom strings of pseudorandom length. (A bash script is provided that will do this for you.) Here is how you will score:
- Let the length of the output program be o.
- Let the length of the input string be l.
- Let a variable r be the result of o/l.
- Find the average of all r: (r1 + r2 + r... + r100) / 100.
Test with this script. You'll have to modify it as instructed. Note that the program does not check whether the output is valid Cubically code. If you can't get the script working, I can help. Ping me in the Cubically chat room.
1Sandbox post – MD XF – 2017-07-21T17:07:51.923
Would "
@6
- print the sum of the nonexistent 6th-indexed face (notepad) as a character" be more accurate? Is%4
also a sum? Are+
commands sum face then add that to all values or...? – Jonathan Allan – 2017-07-21T23:58:25.353@JonathanAllan
@6
/%6
just directly prints the notepad value as a character/integer.@x
/%x
(where x is any existing face) adds all values on thex
-indexed face and prints the sum as a character/integer.+
adds all the values on the specified face to the register. – MD XF – 2017-07-22T01:38:31.023Ah, for some reason I was thinking of the notepad as having 9 values too. – Jonathan Allan – 2017-07-22T01:58:36.950