| Bytes | Lang | Time | Link |
|---|---|---|---|
| 307 | Perl 5 + p0513l012 M5.10.0 | 240816T125713Z | Dom Hast |
| 389 | JavaScript V8 | 210401T101242Z | l4m2 |
| 006 | Deadfish~ | 210401T012224Z | emanresu |
| 290 | CJam | 150124T083602Z | Optimize |
| 703 | ><> | 150124T112938Z | Sp3000 |
| 2035 | Prelude | 150124T095926Z | Martin E |
| 430 | Ruby | 150124T011551Z | histocra |
Perl 5 + -p0513l012 -M5.10.0, 307 bytes, 120 valid permutations
$\.="She put the lime in the coconut, she drank them both up\n";
$_='His sister had another one, she paid it for a lime';
$\.="She put the lime in the coconut, she drank them both up\n";
say'Brother bought a coconut, he bought it for a dime';
$\.="She put the lime in the coconut, she drank them both up\n";
Explanation
This uses the implicit output of -p combined with not requiring any input -0513 to build the string in the right order. The first line is immediately output using say (from -M5.10.0, which adds a newline), the second line is stored in $_ which is implicitly output at the end of the script (from -p), which also outputs $\ as the trailer for the output. $\ (which starts as a newline thanks to -l012) is appended to three times for the last three identical lines.
JavaScript (V8), 389 bytes
a=setTimeout;a(_=>a(_=>print`She put the lime in the coconut, she drank them both up`))
a=setTimeout;a(_=>a(_=>print`She put the lime in the coconut, she drank them both up`))
a=setTimeout;a(_=>a(_=>print`She put the lime in the coconut, she drank them both up`))
setTimeout(_=>print`His sister had another one, she paid it for a lime`)
print`Brother bought a coconut, he bought it for a dime`
Silly
Deadfish~, 6 (it's probably not possible to do more)
{iiiiii}iiiiiic{iiiii}ddcdddciiiiic{d}ddcdddc{i}iiic{{d}ii}ddc{iiiiii}iiiiiic{i}iiiciiiiiic{d}ddddcic{i}iic{{d}ii}ddddc{iiiiii}iiiiic{dddddd}dddddc{{i}ddd}dddc{i}iic{d}ddc{i}iicdc{i}dddcdc{{d}iii}ddc{d}ddc{{i}ddd}iicdddc{{d}iii}ic{iiiiii}iiiiiic{i}iiiciiiiiic{d}ddddcic{i}iic{{d}ii}ddddc{{i}ddd}iiic{i}ic{{d}ii}ddddc{{i}ddd}c{i}dciiic{{d}ii}ddc{iiiiii}iiiiic{dddddd}dddddc{{i}ddd}ddciiiiiciiiic{d}iic
{iii}iic{iiii}c{iii}iiic{i}c{{d}ii}dddc{{i}dd}iiic{d}c{i}cic{d}dddddc{i}iiic{{d}ii}ddc{{i}ddd}iic{d}iiiciiic{{d}iii}iic{iiiiii}iiiiic{i}iiiciciiiiic{d}ddcdddc{i}iiic{{d}ii}ddc{{i}dd}dcdc{d}ic{dddddd}iiic{d}ddc{{i}dd}iiic{d}dcdddc{{d}iii}ic{{i}dd}c{d}dddddc{i}ddcdddddc{{d}iii}iic{{i}ddd}iiic{i}ic{{d}ii}ddddc{{i}ddd}c{i}dciiic{{d}ii}ddc{iiiiii}iiiiic{dddddd}dddddc{{i}ddd}iiiiiicdddciiiic{d}iic
{iii}iic{iiiii}ic{ii}icdddc{{d}iii}ic{{i}dd}ciiiiicdc{{d}ii}ddddc{{i}dd}iiiic{d}ddcdddc{{d}iii}ic{{i}ddd}iiiiiicdddciiiic{d}iic{{d}iii}ic{{i}ddd}iiiciiiiic{{d}ii}iic{{i}dd}iiiic{d}ddcdddc{{d}iii}ic{{i}ddd}dddc{i}iic{d}ddc{i}iicdc{i}dddcdc{{d}iii}ddc{d}ddc{{i}dd}iiic{d}dcdddc{{d}iii}ic{{i}ddd}ddc{i}iiiic{dd}iiic{i}iiicdddc{{d}iii}dddddc{{i}dd}iiiic{d}ddcdddc{i}ddc{{d}ii}iiic{iiiiii}iiiiiic{i}iiiciiiiic{d}ddc{{d}iii}ddc{{i}dd}iiiiicdddddc
{iii}iic{iiiii}ic{ii}icdddc{{d}iii}ic{{i}dd}ciiiiicdc{{d}ii}ddddc{{i}dd}iiiic{d}ddcdddc{{d}iii}ic{{i}ddd}iiiiiicdddciiiic{d}iic{{d}iii}ic{{i}ddd}iiiciiiiic{{d}ii}iic{{i}dd}iiiic{d}ddcdddc{{d}iii}ic{{i}ddd}dddc{i}iic{d}ddc{i}iicdc{i}dddcdc{{d}iii}ddc{d}ddc{{i}dd}iiic{d}dcdddc{{d}iii}ic{{i}ddd}ddc{i}iiiic{dd}iiic{i}iiicdddc{{d}iii}dddddc{{i}dd}iiiic{d}ddcdddc{i}ddc{{d}ii}iiic{iiiiii}iiiiiic{i}iiiciiiiic{d}ddc{{d}iii}ddc{{i}dd}iiiiicdddddc
{iii}iic{iiiii}ic{ii}icdddc{{d}iii}ic{{i}dd}ciiiiicdc{{d}ii}ddddc{{i}dd}iiiic{d}ddcdddc{{d}iii}ic{{i}ddd}iiiiiicdddciiiic{d}iic{{d}iii}ic{{i}ddd}iiiciiiiic{{d}ii}iic{{i}dd}iiiic{d}ddcdddc{{d}iii}ic{{i}ddd}dddc{i}iic{d}ddc{i}iicdc{i}dddcdc{{d}iii}ddc{d}ddc{{i}dd}iiic{d}dcdddc{{d}iii}ic{{i}ddd}ddc{i}iiiic{dd}iiic{i}iiicdddc{{d}iii}dddddc{{i}dd}iiiic{d}ddcdddc{i}ddc{{d}ii}iiic{iiiiii}iiiiiic{i}iiiciiiiic{d}ddc{{d}iii}ddc{{i}dd}iiiiicdddddc
This is so long.....
CJam, 120 valid permutations, 334 299 290 bytes
"She put the lime in the coconut, she drank them both up"N+
"Brother bought a coconut, he bought it for a dime"N+]$~
"She put the lime in the coconut, she drank them both up"N+
"His sister had another one, she paid it for a lime"N+]$~
"She put the lime in the coconut, she drank them both up"N+
Pretty simple logic:
- Put each line of the song in each of the 5 programs
- Wrap everything on stack in an array
- Sort the array
- Unwrap the array so that the next program can use the same logic
- In each step, we have the partial lyrics in an array. Luckily, sorting the array gives the correct order of the lyrics.
UPDATE: Turns out that you don't need the wrap-sort-unwrap cycle after the 3 similar and appearing at the end lines of the song. I can explain why if its not that apparent :)
><>, 120 permutations, 703 bytes
< /a"emid a rof ti thguob eh ,tunococ a thguob rehtorB"0a.#.!50padpacpabpaapa9pa8pa7p97p87p77p67p57p95p84p73p62p51"/////\\\\\>l0=?;o"
< / a"emil a rof ti diap ehs ,eno rehtona dah retsis siH"09.#.!50padpacpabpaapa9pa8pa7p97p87p77p67p57p95p84p73p62p51"/////\\\\\>l0=?;o"
< / a"pu htob meht knard ehs ,tunococ eht ni emil eht tup ehS"08.#.!50padpacpabpaapa9pa8pa7p97p87p77p67p57p95p84p73p62p51"/////\\\\\>l0=?;o"
< / a"pu htob meht knard ehs ,tunococ eht ni emil eht tup ehS"07.#.!50padpacpabpaapa9pa8pa7p97p87p77p67p57p95p84p73p62p51"/////\\\\\>l0=?;o"
</ a"pu htob meht knard ehs ,tunococ eht ni emil eht tup ehS"06.#.!50padpacpabpaapa9pa8pa7p97p87p77p67p57p95p84p73p62p51"/////\\\\\>l0=?;o"
The one-liner restriction was pretty tough for a 2D language, so I had to find a way to make the most of the . teleport instruction.
The initial < makes program flow leftward, wrapping around and executing
"o;?=0l>\\\\\\/////"15p26p37p48p59p75p76p77p78p79p7ap8ap9apaapbapcapdap
This is a series of p (put) instructions which places chars until the board looks like this:
< /<lyrics1>0a.#.!50<blah>
< / <lyrics2>09.#.!50<blah>
< / <lyrics3>08.#.!50<blah>
< / <lyrics4>07.#.!50<blah>
</ <lyrics5>06.#.!50<blah>
/ \
/ \
/ \
/ \
/ \
>l0=?;o
The #.!50 then flips program flow back to rightward again, before jumping to line 5. What follows is this:
- Following the
/mirror on line 5 finds lyrics 5, which is pushed onto the stack. We then teleport to line 6. - Following the
/mirror on line 6 finds lyrics 4, which is pushed onto the stack. We then teleport to line 7. - Following the
/mirror on line 7 finds lyrics 3...
This happens until we push lyrics 1, at which point we teleport to line 10. This is a loop to print the whole stack until it is empty.
If only one line of the program is present, then the \ mirrors do the same job as the teleports on each lyric line.
If the program is scrambled, then the explanation above still applies, so the program works for all permutations!
Prelude, 120 permutations, 2045 2035 bytes
9-9-9-9-9-9-9-9-9-5-97+993++09-9-9-9-9-9-9-1-8992++96+209-9-9-9-9-9-9-1-94+58992++09-9-9-9-9-9-9-1-92+95+199+409-9-9-9-9-9-9-1-58991++09-9-9-9-9-9-9-1-09-9-9-9-9-7-992++993++95+96+396+309-9-9-9-9-9-9-1-58992++09-9-9-9-9-9-9-1-95+909-9-9-9-9-9-9-1-594+993+09-9-9-9-9-9-9-1-58992++09-9-9-9-9-9-9-1-992++993++97+09-9-9-9-9-9-9-1-5809-4- (9+9+9+9+9+9+9+9+9+9+6+!)
9-9-9-9-9-9-9-9-9-5-594+9409-9-9-9-9-9-9-1-109-9-9-9-9-9-9-1-99+96+609-9-9-9-9-9-9-1-992++909-9-9-9-9-9-9-1-992++87993++96+209-9-9-9-9-9-9-1-5809-9-9-9-9-9-9-1-09-9-9-9-9-7-992++993++95+96+396+309-9-9-9-9-9-9-1-109-9-9-9-9-9-9-1-992++87993++96+209-9-9-9-9-9-9-1-99+58992++96+99+09-9-9-3- (9+9+9+9+9+9+9+9+9+9+6+!)
9-9-9-9-9-9-9-9-9-5-97+993++09-9-9-9-9-9-9-1-8992++96+209-9-9-9-9-9-9-1-94+58992++09-9-9-9-9-9-9-1-92+95+199+409-9-9-9-9-9-9-1-58991++09-9-9-9-9-9-9-1-09-9-9-9-9-7-992++993++95+96+396+309-9-9-9-9-9-9-1-58992++09-9-9-9-9-9-9-1-95+909-9-9-9-9-9-9-1-594+993+09-9-9-9-9-9-9-1-58992++09-9-9-9-9-9-9-1-992++993++97+09-9-9-9-9-9-9-1-5809-4- (9+9+9+9+9+9+9+9+9+9+6+!)
9-9-9-9-9-9-9-9-9-5-594+993+09-9-9-9-9-9-9-1-109-9-9-9-9-9-9-1-99+96+609-9-9-9-9-9-9-1-992++909-9-9-9-9-9-9-1-49197+09-9-9-9-9-9-9-1-58991++09-9-9-9-9-9-9-1-09-9-9-9-9-7-595+96+09-9-9-9-9-9-9-1-99+58992++96+95+109-9-9-9-9-9-9-1-41809-9-9-9-9-9-9-1-99+5992++991++9991++09-9-9-9-9-9-9-1-991++909-9-6- (9+9+9+9+9+9+9+9+9+9+6+!)
9-9-9-9-9-9-9-9-9-5-97+993++09-9-9-9-9-9-9-1-8992++96+209-9-9-9-9-9-9-1-94+58992++09-9-9-9-9-9-9-1-92+95+199+409-9-9-9-9-9-9-1-58991++09-9-9-9-9-9-9-1-09-9-9-9-9-7-992++993++95+96+396+309-9-9-9-9-9-9-1-58992++09-9-9-9-9-9-9-1-95+909-9-9-9-9-9-9-1-594+993+09-9-9-9-9-9-9-1-58992++09-9-9-9-9-9-9-1-992++993++97+09-9-9-9-9-9-9-1-5809-4- (9+9+9+9+9+9+9+9+9+9+6+!)
This has ultimately convinced me that Prelude and CJam need a child. If it wasn't for Prelude's very limited instruction set, this submission would actually be very competitive, if it wouldn't even beat CJam.
The basic idea is the following
"push line 4" print
"push line 1"print
"push line 3" print
"push line 2" print
"push line 5" print
In Prelude, each line is its own "voice" with its own stack, and these voices are executed in parallel. That is, in the full program, each line will just individually construct the string and at print it at the end. But due to the offsets of the print statements, the order of the lines doesn't matter at all for the order of the output, since execution is left-to-right, not top-to-bottom.
Now, why are the lines so long? Prelude only stores numbers on its stack. Furthermore, it can only push a single-digit number at a time, so larger numbers have to be constructed from addition and subtraction (there is no multiplication either or other arithmetic either). So the largest part of code is simply calculating and pushing the right character codes. To shorten this a bit, I offset them by 96. At the end, to print, I loop until the stack is empty (i.e. a 0 is encountered), add 96 to each number, and print it.
Note that the strings are pushed in reverse, since they're printed from last to first character.
This assumes the Python interpreter with NUMERIC_OUTPUT = False (which is how the spec defines I/O).
I used the following CJam code to generate the string construction:
"Brother bought a coconut, he bought it for a dime
"W%{i96-_0<{zLa*9/:,'-*'-+0\+}{La*9/:,_,'+*W<}?}%
Lastly, just for fun, why I think this would be really short if Prelude had a concept of strings:
"pu htob meht knard ehs ,tunococ eht ni emil eht tup ehS"N+!
"emid a rof ti thguob eh ,tunococ a thguob rehtorB"N+!
"pu htob meht knard ehs ,tunococ eht ni emil eht tup ehS"N+!
"emil a rof ti diap ehs ,eno rehtona dah retsis siH"N+!
"pu htob meht knard ehs ,tunococ eht ni emil eht tup ehS"N+!
Now the print statements ! are already in the right order, so I wouldn't even need to offset them. I think I'll get down to implementing this some time.
Ruby, 120 valid permutations, 430 bytes
$*[1]='His sister had another one, she paid it for a lime';a||=at_exit{puts($*-[p])}
$*[0]='Brother bought a coconut, he bought it for a dime';a||=at_exit{puts($*)}
$*[2]='She put the lime in the coconut, she drank them both up';a||=at_exit{puts($*-[p])}
$*[3]='She put the lime in the coconut, she drank them both up';a||=at_exit{puts($*-[p])}
$*[4]='She put the lime in the coconut, she drank them both up';a||=at_exit{puts($*-[p])}
Works in any order, or individually. Each line modifies global state, then sets a hook to be executed at the end of the program unless the hook has already been set.