47. Lily, 938 bytes
#16 "(}23!@)" 3//v\D(@;'[af2.q]GkGGZ'#)"14";n4
#/*` "[!PPP(22)SP(>7 7*,;68*,@;'1,@ ␉␉␉␉ q
#>␉
# >36!@␉
#`<`
#<]+<[.>-]>[
#{#z}
#=<xR+++++[D>+++++++L+++<-][PLEASE,2<-#2DO,2SUB#1<-#52PLEASE,2SUB#2<-#32DOREADOUT,2DOGIVEUPDO]>+.---.>][
#Rx%>~~~+ +~*ttt*.x
#D>xU/-<+++Lnd
#R+.----\).>]|
#[#[kGkGx@O6O4/0l0v01k1k(0l0i0jx0h0h1d111x0eU0bx0b0o1d0b0e0e00m1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l11111100^_)46(8+9+9+9+9+=!)
###|
print( (eval ("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))or'({({1})({1}[(0)])}{1}\{1})'#}#(prin 45)(bye)|/=1/24=x<$+@+-@@@@=>+<@@@=>+<?#d>+.--./
__DATA__=1#//
#.\."12"__*
###;console.log 39
""""#//
=begin //
#ssseemeePaeueewuuweeeeeeeeeeCisajjapppp/*/
#define z sizeof'c'-1?"38":"37"
#include<stdio.h>
main( )/*/
#()`#`\'*/{puts(z );}/*'``
$'main'//
#-3o4o#$$$
#<.>"3"O.
=end #//
"""#"#//
#|o51~nJ;#:p'34'\
#ss8␛dggi2␛ `|1|6$//''25 =#print(17)#>27.say#]#print(47)#]#echo 21#ss*///^_^_Z222999"26
␉
is a literal tab, ␛
a literal ESC character; Stack Exchange would mangle the program otherwise. I recommend copying the program from the "input" box of the TIO link below, if you want to work on it.
Try it online!
VIP score): .009034 (to improve, next entry should be no more than 999 bytes)
Rundown
This program prints 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainf***, 40 in Minimal-2D, 39 in CoffeeScript, 38 in C, 37 in C++, 36 in Labyrinth, 35 in INTERCAL, 34 in Rail, 33 in Incident, 32 in Whirl, 31 in Modular SNUSP, 30 in Whitespace, 29 in Trigger, 28 in Brain-Flak, 27 in Perl 6, 26 in 05AB1E, 25 in Pip, 24 in Thutu, 23 in Hexagony, 22 in Underload, 21 in Nim, 20 in Prelude, 19 in Reng, 18 in Cardinal, 17 in Julia, 16 in Pyth, 15 in Haystack, 14 in Turtlèd, 13 in Ruby, 12 in Fission, 11 in Befunge-98, 10 in Befunge-93, 9 in Perl 5, 8 in Retina, 7 in Japt, 6 in SMBF, 5 in Python 2, 4 in ><>, 3 in Minkolang, 2 in V/Vim, and 1 in Python 3.
Verification
Most of the languages are tested by the test driver shown above.
Reng can be tested to output 19 here. I’m not positive this doesn’t have an error, if someone could verify…?
Modular SNUSP can be tested to output 31 here.
Cubix’s cube shape viewed here
Incident is checked by keeping the tokens balanced as described in previous answers.
VIP
I’m happy to announce that with the addition of Lily today, we officially have the lowest VIP score of all time. And so, I do hereby proclaim that this polyglot, at the time of writing, to be unequivocally the greatest polyglot of all time. Congratulations to all contributors.
Because we’ve finally achieved this self-imposed goal, and because I ended up touching code for damn near all the languages this round, I’ve added a small code snippet from each language along with the code change description. The purpose of these is to provide a place to search for code snippets from the polyglot for research starting point.
For example, if you want to make a change to this 8+9+9+9+9+
you could search for this string, to find that it’s part of Prelude’s code. Then, you may wish to read over the original prelude answer, look at some prelude code changes that have been made, or review the Prelude documentation for alternative solutions.
State of the Test Driver
I copied @SnoringFrog’s Alphuck Transpiler into the Test Driver for viewing the Alphuck code’s in the BrainF*** character set. I found it much easier to debug this way, and I suspect others would as well.
I also added titles to the Extra Information outputs since Alphick’s output is easy to confuse with BF if you’re not familiar with the Bash script.
Lily
]#print(47)#
Nim, we know from this polyglot, uses #[
and ]#
for block comments and according to this tip for creating polyglots, Lily uses the same syntax for block comments. So, I wondered if I could find a truthy/falsey abuse to create different outputs, but alas I could not.
Then while browsing Rosettscode.org for unused block comment structures, I came to this post about Nim, and realized it was wrong in its assertion that Nim only has single-line comments. Then I checked Lily’s post and it too failed to mention block comments. (Sadly, I did not have permission to edit the posts.)
Then I went ahead and looked at Nim and Lily’s documentation, just to make sure I wasn’t crazy and I saw an exploitable difference. Nim allows nested comments.
I sat on this knowledge for months, thinking it would be my final addition to the polyglot because it was virtually guaranteed to be available at any time considering its block comment structure was already included, and because it was so under documented.
Over the months, it occurred to me that abusing nested block comments is not a trick that’s not documented in the Tips for Creating Polyglot thread, so I added it. My explanation used a simplified Lily/Nim polyglot as an example, so I’ll refer you to that post if it’s not obvious how I abused this language feature.
CoffeeScript
###;console.log 39
One of Lily’s features is that ###
is used to attach a docstring to a function, so if you use this without following it with what Lily views as a function, then Lily will error out. And since ###
is CoffeeScript’s block comment, the ###
on the INTERCAL line had to change. So the final two #
got cut from this line and moved to the line after Lily’s #[
block comment so Lily would view it as a comment instead of a doc string.
Julia
=#print(17)#
By moving the two ##
for CoffeeScript, a hole was opened up on the INTERCAL line. The spacing on this line is delicate because Minimal-2D is looping between the beginning of this line and the line two below. So I had to fill the space. The first byte I filled with Julia’s initial block comment command (#=
) by moving the =
down to fill the space. This move also helped as a partial solve for Labrynth’s final answer, which I talk about later.
BrainF***
+++++[D>+++++++L+++<-]
>+.---.>
The second space opened up by the CoffeeScript move still needed to be filled, and the >
at the end of the line above was an easy move. This character set up the proper memory cell for BF so it just needed to go anywhere in the correct order of BF characters, and since there were no BF characters between the old and new location, no problem.
Brain-Flack
({({1})({1}[(0)])}{1}\{1})
In the process of working a different solution, I had an epiphany about old this Brain-Flak code: (\{(\{})(\{}[()])}\{}\{}\{})
. I was using \
to escape out {
for Japt, but I could put a 1
in each curly brace, to give Japt something to do like I did in the PicoLisp answer. But what would that give me? Trading a \
for any other instruction was at best an even byte swap. But wait… Retina.
Retina had a string of 1
s in the same line that were somehow integral to its answer. So I tried moving the 1
s over to Brain-Flak’s code to handle Japt and it worked almost entirely.
Thutu, didn’t like having the last \
removed from this snippet, so I left it. I had one fewer 1
in Retina’s code than I required to fill Japt’s braces anyways, so it all worked out rather swimmingly to golf down 5 bytes and produce this: ({({1})({1}[(1)])}{1}\{})
.
Later I found I had to swap around 1
s because The above tokenized {1}
for Incident. So I swapped around the 1
s to make ({({1})({1}[(0)])}{1}\{1})
.
Modular SNUSP
<$+@+-@@@@=>+<@@@=>+<?#>+.--.
While I was looking at the big line, I decided to look at some other languages. Modular SNUSP is encased in a pair of []
, to protect the code from SM/BF. But SM/BF were both already jumping this code because of the [
on line 14. Cut.
Thutu
|/=1/24=x
I never bothered to learn how Thutu works, but I do know that it’s answer was somehow produced in part by |=/=1/24=x=9
, so I experimentally, removed various characters and verified that the same results were produced, and found I could get there with less. Golfed!
INTERCAL
[PLEASE,2<-#2DO,2SUB#1<-#52PLEASE,2SUB#2<-#32DOREADOUT,2DOGIVE]
I swapped some Latin FAC
s for English DO
s because it was byte saving, and all the D
s worked safely as Fusion starting points with INTERCAL’s new location.
Hexagony
"(}23!@)"
Here’s where things got messy. I got it in my head that Hexagony’s code module should really, really go inside C/++’s preprocessor directive on line 1. The benefit here is that Hexagony would be permanently be solved because its pointer always starts on line 1 heading to the right, which puts its output command prior to any hexagon wrapping non-sense. And with Cubix in the mix now, providing basically the same headache… Well let’s just do this with 1 language, yeah?
So }23!@
appears in line 1 now, and everything that follows is a consequence of that move. Note that the }
is still needed to clear the top value of the stack due to the preceding (
in the final solution.
Pyth
#16
;'[af2.q]
The first problem was moving Pyth’s answer to somewhere else. I spent quite a while looking through Pyth’s documentation for a way to pop the string off the stack or something, before stumbling into the answer. For Pyth, a space preceding any command causes the command to be skipped. This actually works for a full string, like where our Hexagony capsule is residing, so the first x characters of the polyglot became #16 "}23!@"
, with the 16 here now being Pyth’s answer.
Underload
(22)S
Underload needed the Hexagony capsule to exist within a pair of parenthesis, but if too much of the polyglot went into that first set of parentheses Underload would bomb out. Also, our last few solutions had an open ended (
on line 1, which was preceded by a \
for Retina to escape it out of consideration. (Retina didn’t like the imbalanced ()
.) But now, this solution didn’t work for Retina if there was already a pair of ()
in the line. The new solution opens and closes 2 sets of parenthesis on line 1 to get around these problems. Fortunately Underload didn’t complain before a new set of parenthesis could be opened on line 2.
Meanwhile, inserting more text in line 1 prior to the v
causes line 2 to require a bunch of filler characters prior to its >
, which is the Befunge code path. The largest piece of lose code that could fill the hole was Underloads answer statement (22)S
which got moved earlier in line 2 along with some related Alphuck P
s that needed to appear prior to s
’s for its jump. (More on Alphuck later.)
Trigger
GkGGZ
Z222999
Trigger’s jump code got pushed out of line 2 by Underload’s shift, so it had to go somewhere and the earlier the better. The Japt string '[af2.q]’ in line 1 turned out to be a well-hidden location, so I plopped Trigger jump code there after Pyth quit, making '[af2.q] GkGGZ’.
You may notice that the letters in the jump code got changed again, this is partly because I wanted to leverage the space for a polyglot unique Incident jump token, and partly because of a problem caused by… wait never mind. I just uppercased the G
s for no good reason. Ok, whatever.
SMBF
<]+<[.>-]>[
With characters spaces to fill prior to the >
on line 2, I moved the [
back in the line to help fill the hole. You might think as I did that it might be possible to golf off this character all together, as well as the ]
on line 1, but this causes Retina to get grumpy, as it did with Underload. And even if you think about throwing a \
prior to [
might fix Retina, you would be right, but it would cause 05AB1E to fail in a way that I presume cannot be fixed with a zero byte budget. So I didn’t bother.
Turtlèd
#)"14"
I managed a line 1 character order that didn’t necessitate the # #
therein. So the turtle no longer pokes his head out of the shell before finding “14”
.
Labrynth
# >36!@
The maze got kinda messed up by all the shifts for Hexagony. The biggest problem was that the old solution relied on the second character in the polyglot being a space (aka maze wall). Now the pointer turns right once it passes into the 1
on line 1, which was a problem because the /
on line 2 set the top of the stack to 0, which caused the pointer to really want to go straight.
Trial and error montage
This got solved by putting a >
in the path of the pointer after the /
, which is an instruction to shift all of row 3 one cell to the right. This puts the pointer in column 3 as it continues its zero valued straight path to the >
in >36!@
which again shifts; this time row 4. From this point, the pointer turns to head down line 4 which from that point forward is a 1 way trip to the end of the maze.
@SnoringFrog made a gif of Labrynth's code path to help someone with an answer, and I thought it was cool and helpful enough that it should be added here.

Japt
`|1|6$`
I golfed some other bytes off of line 1. It was all trial and error and I have no idea how Japt works for the most part. I guess I can say that in the #
near the end of line 1 causes Japt to take the ascii value of the )
. Most everything else is a mystery.
Minimal-2D
#=<xR+++++[D>+++++++L
#Rx%>~~~+ +~*ttt*.x
#D>xU/-<+++Lnd
#R+.----\).>]|
Part of the line 1 refactor was to place the D early enough in the line to minimize the amount of empty space thrown into line 8, where Minimal 2-D catches the code path From the D
to L
. I ended up being able to place the \D
just after the v
in line 1, which ended up being the same column it started in, so I didn’t have to touch line 8.
Befunge
7 7*,;68*,@
The space between the 7
’s on line 2 is a spacing shift for Minimal-2D’s D
on line 1 so that Fission doesn’t pass through a character. The 7 that Fission would otherwise pass through here doesn’t actually cause a problems, but the space is part of White space’s answer, so it needs to appear somewhere on the line, and this seemed like a better place than most.
Befunge-98
>7 7*,;68*,@;'1,@
For some reason the Hexagony capsule gave a problem for Befung-98. I believe it was producing non-deterministic results for a while there. I don’t know what the issue was, because I went back and looked at an old solution for inspiration and saw that there was a @ before it quit in prior solutions, so I tried it and it worked.
Reticular
;#:p'34'\
Reticular, Haystack, and Reng, which all wrap around the polyglot when they hit the first /
on line 1, had to be redone because we’re wrapping on a later column than in previous solutions. Now the code path goes through the 6
on the final line, which gets buried in a stack values for these languages, and continues to the \
on the next to last line which catches the code path, and pushes these languages’ pointers to the left.
Reticular was the problem child of the bunch because it had a command in the Hexagony capsule, which it traversed prior to wrapping, that caused the old solution to break on Reng’s code. I solved this by throwing Reticular’s code first in the order.
Reng
~nJ
The ;
, which terminated Reticular, gave Reng some problems because it views the command as a reflector. So Reng gets a #
jump command to skip past the ;
. But Reticular threw an error on the #
, so I tossed in a preceding :
to indicate that the following #
was to be pushed onto the stack as a string.
Haystack
|o51
Haystack’s old solution was too long, unless I was going to wrap up to another line, but I no longer needed to use the old solution because I was terminating Reticular earlier, so I reverted to the old solution of outputting a string rather than ascii values, which was shorter, allowing the 3 languages to exactly fit in one line.
Minkolang
$$$
#<.>"3"O.
The change to remove the space before the first number in line 1 caused Minkolang to fall through time a in column 4. The upshot of this was I could golf out a bunch of the junk that had to be thrown into Minkolang’s code line because it previously couldn’t start with a #
. The .
in the final solution is both needed as a placeholder, and to detokenize .>
.
Incident
kGkG0l0v0@O6O4/1k1k0l(0i0jx0h0h1d111x0eU0bx0b0o1d0b0e0e00m1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l11111100^_
^_^_
I think @SnoringFrog, during his week of all-nighters and fantastic code golfing, changed the incident token 0e
to 0ee
, presumably to make Cubix work. I found I could once again set this token back to 0e
to save a few bytes.
I also went through the polyglot and re-tokenized any Incident tokens that were littered about. I ended up putting just a few back. One I mentioned is the .
in <.>
. Another is the !
in [!PPP
on line 2. The nd
in +Lnd
is a detokenizing string as well that I couldn’t otherwise fit into a place holding gap.
PicoLisp
}#(prin 45)(bye)
The location of PicoLisp’s instructions became kind of a problem because Prelude’s parenthesis budget got shifted by Underload’s change. So I just moved PicoLisp’s answer. Putting all these parenthesis so close to column 1 was just asking for trouble anyway. Code is now in the Python line, which is safer.
Alphuck
ssseemeePaeueewuuweeeeeeeeeeCisajjapppp
This is my first time working with Alphuck and it is surprising how much it doesn’t feel like BrainF***. Just the fact that all the characters show up all the time makes the language much harder to work with. And it’s much more difficult to read. Anyways, the PicoLisp move changed the []
balance (speaking in BF terms) so I had to add back some s
’ in the evil line and the last line.
Prelude
46(8+9+9+9+9+=!)
Prelude had all kinds of rearrangements due to the Underload move. But these we’re mostly just the spacing shifts we’ve all become accustomed to. The one large change was to move the )
now seen in #R+.----\).>]|
from the end of the line above. To leave it in its old home required too many spaces. Experimentation showed there was a happy home a few columns left of its original spot and the the characters to the left were all rigidly incorporated into the Minimal-2D solution. So the next best move was to go down a line where Minimal-2D was more flexible and Underload was still happy.
Retina
({({1})({1}[(0)])}{1}\{1})
|1|6
Retina had a small problem with the Prelude move discussed above however. The line change put the hanging )
on a cares-about-symbol-balance line, so preceding \
was thrown in to placate Retina. We were still byte saving from the number of spaces Prelude needed on the line above, so we were good with this result.
Cubix
@O6O4/
While I loved the elegance of the Cubix Placement in the last answer it was fragile, and yeah I broke it with all this stuff I did. So I stepped through the Cubix interpreter to find a good place to catch the code path and ended up hooking it in the Incident/While line, which is a pretty good place to catch it because the Cubix module could mostly slide freely throughout the line. The only catch was that you had to be very careful not to place Cubix inside an incident token. All the incident tokens in this space start with either a 1
or a 0
and are followed by a letter, other than x
. x
in this space appears to be a de-tokenizer. Fortunately Cubix slipped in between tokens without a spacer.
Whitespace
Or
␉␉␉␉
There were a few hidden tabs left over from earlier Whitespace solutions that were still needed as whitespace for whatever other languages were in the region. So I swapped these out for plain old spaces, just for the convenience of reading.
And that was the last of my code changes. Here are the few languages I didn’t touch.
evil
meePaeueewuuw
Cardinal
x%>~~~+ +~*ttt*.x
C
#define z sizeof'c'-1?"38":"37"
#include<stdio.h>
main( )/*/
#()`#`\'*/{puts(z );}/*'
``
C++
#define z sizeof'c'-1?"38":"37"
#include<stdio.h>
main( )/*/
#()`#`\'*/{puts(z );}/*'
``
Rail
$'main'//
#-3o4o#
Python 2
print( (eval ("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))
Python 3
print( (eval ("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))
Ruby
print( (eval ("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))
Perl
print( (eval ("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))
__DATA__=1#//
Perl 6
#>27.say#
05AB1E
"26
Pip
''25
Whirl
0l0v0@O6O4/1k1k0l(0i0jx0h0h1d111x0eU0bx0b0o1d0b0e0e00m1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l11111100
Fission
#.\."12"__*
V
dggi2
Or
␛ dggi2␛
><>
;n4
Nim
]#echo 21#
Going Forward
While trying to prove to my insistent brain that Octave was an impossible addition, I instead proved that actually will fit in here. It requires a bit of comfort with tricking Japt around curly braces and a rather interesting 3 language solve, but it is possible.
The polyglot currently executes in Objective-C (clang) to produce 38 (the C answer). I’ve looked for a language native method for differentiating from C, but haven’t had any luck. Clang has pre-defined macros like TIME that are not used in the C/C++ compiler we’re so far using. But I’d prefer to find a language native method of differentiating Objective-C is possible. Any ideas?
And along those lines, I think we’re at a point where we’re soliciting ideas from the community. I know my idea bank is running low, so if you have any suggestions, please leave a comment.
Also, a special shout out to @WheatWizard for suggesting Glypho as a possible addition as well. I haven’t looked too deeply at it yet, but I am intrigued.
3
For people who can see deleted posts: the Sandbox post was here.
– None – 2016-12-06T19:00:09.6531How should permalinks be updated? Should the newest answer contain permalinks of all the previous languages? – Cows quack – 2016-12-06T19:41:37.170
5There's no need to copy the previous program, although of course you can use it as a guide; redoing the program from scratch is likely to take longer! There's no need to permalink to answers; sorting by oldest will show all the answers in order already. – None – 2016-12-06T19:44:38.350
3@ais523 I think what was meant was that should new answers contain try it links with the new code? – Blue – 2016-12-06T19:45:46.623
In hindsight there could have been a requirement to check validity of answers before new answers can be posted, e.g. in meta regex golf.
– Sp3000 – 2016-12-07T09:31:21.583Is it ok if the language does not have an online interpreter, but has one on github (but has to be downloaded)? – Cows quack – 2016-12-07T09:38:59.820
As PPCG rules require allowing as many languages to compete as reasonably possible, I don't think it can be fair to require there to be an online way to test the program (and the post as currently written doesn't), although you must of course give people some way to test. Perhaps you could try to persuade one of the online language hosts to add the language you're thinking of, though, to make things easier? – None – 2016-12-07T13:14:15.747
@ais523 I have already written an online interpreter (based on the GH code) for haystack, but I will ask someone to add the language on TIO, thanks! – Cows quack – 2016-12-07T18:11:05.980
5I think we need a script that takes a hex dump of the code and automatically runs it in all the languages... – mbomb007 – 2016-12-07T20:05:06.333
Is it okay to exit with a non-zero error code that is not crashing, e.g. Befunge-98's
q
command? – Sp3000 – 2016-12-07T21:07:58.313@Sp3000: Yes. Intentionally reporting failed execution is distinct from a crash. – None – 2016-12-07T21:37:03.313
3
This is the Versatile integer printer posted as a different type of challenge. (Inspiration?) The final answer (currently) would score
– Stewie Griffin – 2016-12-17T12:11:47.8270.0127
, only beaten by Sp3000's 30 language submission... :)1
@StewieGriffin I actually just added a snippet to my last answer that shows the scores for all the answers if they'd been submitted for that challenge
– SnoringFrog – 2017-02-06T17:27:49.867This challenge is perfectly described by its tags: [polyglot] [answer-chaining]. – Esolanging Fruit – 2017-05-29T20:52:36.793
Can we use languages that were "created" (pushed to GitHub) barely a month after the challenge? – MD XF – 2017-06-02T02:34:43.337
@MDXF: Unfortunately no. PPCG rules are fairly frustrating for a challenge like this, but if you start violating them, you end up in a subjective minefield of what is and isn't legal. – None – 2017-06-02T06:21:54.720
@ais523 that's disappointing. I was going to add ;# cause it's quite easy – caird coinheringaahing – 2017-06-05T17:05:11.380
@cairdcoinheringaahing I really doubt it would be as easy as you think. There are quite a few
#
's in the code, and it wouldn't be possible to just add random;
's. – MD XF – 2017-06-05T22:03:57.007@MDXF it's probably the easiest language of all of them to add given that it was designed for polyglot Kolmogorov complexity challenges (# and ; are common comment symbols – caird coinheringaahing – 2017-06-05T22:09:43.760
@StewieGriffin it is now under
0.003
:) – MD XF – 2017-07-31T18:22:04.473@cairdcoinheringaahing Yeah, except there are already about 300 instances of
#
in the code. – MD XF – 2017-07-31T18:22:59.947This challenge has been linked from the Wikipedia article on Polyglots. – ppperry – 2017-08-20T02:09:25.983
Are we going to award the accepted answer to anyone else than stasoid and potato44? Because they did most of the answers? – Michthan – 2017-09-27T06:21:43.303
@Michthan The accepted answer would have gone to the winner, which in this case is the second newest answer when 14 days have passed since the most recent answer. But because ais523 is no longer a member of PPCG no answer will get accepted as he isn't here to do so. – Potato44 – 2017-09-27T07:21:00.517