Add a language to a polyglot

188

68

This is an challenge in which each answer builds on the previous answer. I recommend sorting the thread by "oldest" in order to be sure about the order in which the posts are made.

Note: This has become quite a long-lasting challenge, and posting new answers is fairly difficult. As such, there's now a chat room available for this challenge, in case you want advice on a particular part of a potential answer, have ideas for languages that could be added, or the like. Feel free to drop in if you have anything to ask or say!

The task

The nth program to be submitted must run in n different languages; specifically, all the languages added in previous programs to be submitted, plus one more. The program must output 1 when run in the first language used in answers to this question, 2 when run in the second language, and so on. For example, the first answer could print 1 when run in Python 3, and the second answer could output 1 when run in Python 3 and 2 when run in JavaScript; in this case, the third answer would have to output 1 when run in Python 3, 2 when run in JavaScript, and 3 when run in some other language.

Additional rules

  • Your program must run without erroring out or crashing. Warnings (and other stderr output) are acceptable, but the program must exit normally (e.g. by running off the end of the program, or via a command such as exit that performs normal program termination).
  • The output must be only the integer, but trailing newlines are OK. Also leading and trailing spaces are allowed but only if language has no way to print without them (example: Zephyr).
  • Each answer must be no more than 20% or 20 bytes (whichever is larger) longer than the previous answer. (This is to prevent the use of languages like Lenguage spamming up the thread, and to encourage at least a minor amount of golfing.)
  • Using different versions of the same language is allowed (although obviously they'll have to print different numbers, so you'll need to fit a version check into the polyglot). However, you may not use a language feature that returns the language's version number. Repeating the exact same language is, obviously, impossible (as the program would have to deterministically print one of two different numbers).
  • Tricks like excessive comment abuse, despite being banned in some polyglot competitions, are just fine here.
  • You don't have to use the previous answers as a guide to writing your own (you can rewrite the whole program if you like, as long as it complies with the spec); however, basing your answer mostly on a previous answer is allowed and probably the easiest way to make a solution.
  • You cannot submit two answers in a row. Let someone else post in between.
  • As this challenge requires other competitors to post in the same languages you are, you can only use languages with a free implementation (much as though this were a contest).
  • In the case where a language has more than one interpreter, you can pick any interpreter for any given language so long as all programs which are meant to run successfully in that language do so in that interpreter. (In other words, if a program works in more than one interpreter, future posts can pick either of those interpreters, rather than a post "locking in" a particular choice of interpreter for a language.)
  • This challenge now uses the new PPCG rules about language choice: you can use a language, or a language interpreter, even if it's newer than the question. However, you may not use a language/interpreter that's newer than the question if a) the language was designed for the purpose of polyglotting or b) the language was inspired by this question. (So newly designed practical programming languages are almost certainly going to be OK, as are unrelated esolangs, but things like A Pear Tree, which was inspired by this question, are banned.) Note that this doesn't change the validity of languages designed for polyglotting that are older than this question.
  • Note that the victory condition (see below) is designed so that breaking the chain (i.e. making it impossible for anyone else to answer after you via the use of a language that is hard to polyglot with further languages) will disqualify you from winning. The aim is to keep going as long as we can, and if you want to win, you'll have to respect that.

Answer format

As all the answers depend on each other, having a consistent answer format is going to be helpful. I recommend formatting your answer something like this (this is an example for the second link in the chain):

2. JavaScript, 40 bytes

(program goes here)

This program prints 1 in Python 3, and 2 in JavaScript.

(if you want to explain the program, the polyglotting techniques, etc., place them here)

Victory condition

Once there have been no new answers for 14 days, the winner will be whoever posted the second newest answer, i.e. the largest polyglot that's been proven not to have broken the chain. Extending the chain after that is still very welcome, though!

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

3

For people who can see deleted posts: the Sandbox post was here.

– None – 2016-12-06T19:00:09.653

1How 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.583

Is 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 0.0127, only beaten by Sp3000's 30 language submission... :)

– Stewie Griffin – 2016-12-17T12:11:47.827

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.867

This 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.947

This 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

Answers

68

Note: If you see this first, you might want to sort by oldest

17. Julia (128 bytes)

#v`16 "<" 6/b0\ .q@#;n4"14""
#>3N9@15o|R"12"*^
#=|
print((1/2and 9 or 13)-(0and+4)^1<<65>>62);# =#;print(17)
#gg99ddi2` |1|1+6

There are two ESCs on the last line, one before the first g and one after the 2. This could be golfed more, but things got messy no thanks to V and Pyth.

Prints 1 in Python 3, 2 in V, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtléd, 15 in Haystack, 16 in Pyth and 17 in Julia.


Hints:

  • The start of the fourth line is Python 2/3, Perl, Ruby. The end is Julia, thanks to #= multiline comments (note that Julia doesn't have and/or).
  • V is <ESC>gg99ddi2<ESC>, which is definitely golfable but V is annoying to test on Try it online! since the interpreter is fairly slow.
  • Minkolang and Haystack go down at the first v. Befunge-93 and -98 don't, and depend on a b.
  • Retina counts the number of spaces and 1s in the fourth line, and V hides in the config for Retina (i.e. before the backtick).
  • Per @ETHproduction's hint, Japt uses backticks to hide the majority of the code in a string.
  • Fission is R"12"*.
  • SMBF has been golfed to <. in the first line, plus the final 6.

Sp3000

Posted 2016-12-06T18:59:02.963

Reputation: 54 224

20Where has everyone else's code gone though – Alfie Goodacre – 2016-12-07T14:56:59.673

10159 bytes to 128 bytes? Wow, that's some excellent golfing! – Cows quack – 2016-12-07T15:00:18.090

6Nice, 2^7 bytes – tomsmeding – 2016-12-07T15:45:32.697

1I was working on a 99 version for 17, I got it within 2 bytes of the rules and then you come in with this huge improvement! I'm never going to get 99 into this aha. – Teal pelican – 2016-12-07T16:02:49.190

If you're going for golfing, the V section could be shortened to &lt;esc&gt;HcL2&lt;esc&gt;. Of course, I don't know if this would mess with the other languages or not. – DJMcMayhem – 2016-12-07T17:32:42.940

5Wow... incredible! We're going to have to write up a new explanation for every language when all's said and done ;-) – ETHproductions – 2016-12-07T17:32:58.050

@mbomb007 ah fair enough, I had assumed it had to build on the others – Alfie Goodacre – 2016-12-07T20:07:01.760

3@AlfieGoodacre "You don't have to use the previous answers as a guide to writing your own (you can rewrite the whole program if you like, as long as it complies with the spec)" – mbomb007 – 2016-12-07T20:07:45.147

2+1 for significant golfing of the polyglot – mbomb007 – 2016-12-07T20:08:06.590

amazing, 101 lang)) – Евгений Новиков – 2017-07-31T11:41:01.220

47

23. Hexagony, 186 bytes

Sorry if this messes up plans...

#v`16/"<"6/b.q@"(::):::  (22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++~~~%
#=~nJ<R"12";
#[

print((1/2and 9 or 13)-(0and+4)^1<<65>>62)#46(89999+++++!)=#print(17)#0\32=""<0]#echo 21
#8␛dggi2␛` |1|6

␛ is used to represent a literal ESC character.

Prints:

23 in Hexagony, 22 in Underload, 21 in Nim, 20 in Prelude, 19 in Reng (testable here), 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, 8 in Retina, 7 in Japt, 6 in SMBF, 5 in Python 2, 4 in ><>, 3 in Minkolang, 2 in Vim/V, and 1 in Python 3.

To get to the unlinked languages, click the change language button in the upper right of the Hexagony link.


Hexagony isn't readable (at ALL) in this format. We need to look at it in hexagonal form.
Note that the 2 ESC characters have been replaced with s so you can see them - they are ignored, so there are no others in the program:

        # v 1 6 / " < " 6
       / b . q @ " ( : : )      A lot more readable, right?? No?
      : : : ( 2 2 ) S # ; n
     4 " 1 4 " # > 3 N 6 @ 1
    5 o | > ^ * t t t * ~ + +
   ~ ~ ~ % # = ~ n J < R " 1 2
  " ; # [ p r i n t ( ( 1 / 2 a
 n d 9 o r 1 3 ) - ( 0 a n d + 4
) ^ 1 < < 6 5 > > 6 2 ) # 4 6 ( 8   | Note that the 0s below can be replaced
 9 9 9 9 + + + + + ! ) = # p r i    | With anything (except "`" or " "), 
  n t ( 1 7 ) # 0 \ 3 2 = " " <     V as far as Hexagony is concerned
   0 ] # e c h o 2 1 # 8 ␛ d g
    g i 2 ␛ | 1 | 6 . . . . .    <-- the ␛ represents an esc
     . . . . . . . . . . . .         character
      . . . . . . . . . . .
       . . . . . . . . . .       A "." is a no-op
        . . . . . . . . .
                ^
                | Mirror wraps to here, going NW

For those unfamiliar with Hexagony, There are 6 IPs, which start at the 6 corners. Only 1 is active at a time, and are switched by using #][. The memory model isn't that important to this program, but might be necessary to understand in the future. All that you need to know is that 1 int is stored in a "memory edge" (ME for short), and '"}{ change the ME that is active.

\/|_>< are mirrors that control program flow.

This is how it works:

First line executed:

#       A no-op (sets active IP to 0, the currently active one)
 v      letter chars set the ME to their ASCII value - so ME is now 118
  16    Like Labyrinth, 0-9 multiplies ME by 10 and is added - ME now 11816
    /   A mirror that sends IP going NW by wrapping to the bottom

The bottom (snippet flipped vertically so you can read up to down):

    .   
   .    A series of no-ops. The IP is going NW now,
  .     because of the mirror on the top.
 .
|       Another mirror. This one sends the IP NE, into the h
 h      sets the ME to 104, the ASCII value for h
  #     104 % 6 == 2, so IP 2 is now active instead of 0

The right edge:

        8  IP #2 is moving SW, starting in the right corner 
       i   Sets the ME to 105
      <    Mirror. Sends the IP going due West
    ""     These change the Active ME - just know that the new edge is 0
   =       Changes the MP (more in specs) - effectively a no-op used to fill space
\32        pushes 23, and mirrors up NE to the !

The last bit of relevant code:

!          Prints the current value of the ME as an int. Success!
 20(R~     Does things to the ME - irrelevant now
      @    Ends the program!

Things to note:

  • Hexagony drops all s and `s before executing, so any changes to those will not affect Hexagony
  • I needed to pad the code so that it would be interpreted as a 9 length hexagon, instead of an 8th - be careful golfing below 169 or above 217 relevant characters
  • Because of this, the ~~~ and the 2 0s at the end can be changed at no harm to the code
  • The ="" just moves the ME away from the previous one so that a new ME can be modified. They can be replaced with other characters that do the same thing at no harm to the hexagony program ('s, for example)
  • This is technically not comlient with the Befunge 93 specs, because it limits the bounding box of the code to 80 by 25 chracters. However, Most interptreters ignore this spec (like TIO), So I don't personally think it's that big of a deal. If you do, feel free to leave a comment. (If enough really want me to change it, then I will try)
  • Hope it's not too hard now.

Mistah Figgins

Posted 2016-12-06T18:59:02.963

Reputation: 2 362

This could easily become the most crazy program flow if done right. I was close to getting it done with a size 8 hexagon through some crazy @## method, but 9 was a lot easier once I tried that. Also, v1 of TIO works a lot faster, but you can't switch languages easily.

– Mistah Figgins – 2016-12-09T05:38:18.777

I would suggest Labyrinth next, but I want to do that one. – Mistah Figgins – 2016-12-09T05:46:24.467

I'm not skilled enough to write anything like this myself, but in the mean time I'm waiting for Cubix to pop up. – Pavel – 2016-12-09T06:22:25.850

@pavel I'm not familiar with that language. I assume it's 3D. Sounds cool. There's also some funges that are 3D, might be an interesting addition – Mistah Figgins – 2016-12-09T06:36:12.910

I suspect it's easiest to maintain something like this flow as long as we're still at this side length, and just rewrite the Hexagony code when we go up to the next size. With respect to 3D languages, Trefunge should be fairly easy to fit in, assuming that none of the existing languages panic upon seeing formfeeds. (Also, Cubix was posted earlier but deleted because the poster thought it might be too hard; maintaining Hexagony and Cubix at once could be fairly confusing…) – None – 2016-12-09T07:49:13.133

@MistahFiggins Cubix is also 2D (the source code is wrapped around the sides of a cube), and it uses the same implicit code layouting as Hexagony (it removes whitespace, pads the source to the smallest possible full cube, and then assigns the cells to their positions). – Martin Ender – 2016-12-09T10:47:16.960

In a sense this technically doesn't work in Befunge-93 for a spec-compliant interpreter, since the Befunge-93 spec has a fixed size playing field. Might be worth noting. – Sp3000 – 2016-12-09T13:12:39.100

@Sp3000 Ah, I had forgot about that. Most compilers ignore this, as far as I know, because it's pretty annoying. However, if you all think it's a big enough deal, I could try to edit it down to a size 8 triangle where most of the new characters are on the 2nd line. (It would probably take just as long to explain it, lol) – Mistah Figgins – 2016-12-09T16:45:21.903

I think it's fine if you mention your assumptions about the interpreter/compiler and note that it's technically not spec compliant. In a sense, it's just like having a slight variant of the language (cue language-is-defined-by-implementation meta comment). – Sp3000 – 2016-12-09T17:07:51.770

43

50. bash, 1024 bytes

#16  "(}23!@)" 3//v\D(@;'[af2.qc]GkGGZ'#)"14";n4
#/*` "[!PPP(22)SP(>7 7*,;68*,@;'1,@ ␉␉␉␉ q
#>␉
# >36!@␉
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=<xR+++++[D>+++++++L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52PLEASE,2SUB#2<-#32DOREADOUT,2DOGIVEUPDOiiipsddsdoh@O6O4/]>+.-- -. >][
#Rx%>~~~+ +~*ttt*.x
#D>xU/-<+++L
#R+.----\).>]|
#[#[/v/v(/0l0v01k1kx0l0ix0jor0h0h1d111x0eU0bx0b0o1d0b0e0e00m1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l111111^_)  0046(8+9+9+9+9+=!)
###|
'\';echo 50;exit;';print((eval("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))or"'x"or'({({1})({1}[(0)])}{1}\{1})'#}#(prin 45)(bye)|/=1/24=x<$+@+-@@@@=>+<@@@=>+<?#d>+.--./
__DATA__=1#"'x"//
#.\."12"__*'
###;console.log 39
""""#//
=begin //
#ssseemeePaeueewuuweeeeeeeeeeCisajjapppp/*/
#define z sizeof'c'-1?"38":"37"
#include<stdio.h>
main(  )/*/
#()`#`\'*/{puts(z );}/*'``
<>{# }//
#}
disp 49#//
#{
1}<>//
$'main'//
#-3o4o#$$$
#< >"3"O.
=end #//
"""#"#//
#}
#|o51~nJ;#:p'34'\
#ss8␛dggi2␛ `|1|6$//''25  =#print(17)#>27.say#]#print(47)#]#echo 21#ss*///nd^_^_Z222999"26

Want to learn more? Try the polygot chat!

Try them online!

As usual, I replaced literal tabs with and literal ESC characters with , due to limitations of Stack Exchange. You can get an easily copiable version of the program from the "input" box of the TIO link above.

Rundown

This program prints 50 in bash, 49 in Octave, 48 in Deadfish~, 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 above. The usual four culprits need testing separately:

  • Incident was tested using its official interpreter, offline;

  • Deadfish~ was also tested using its official interpreter, offline;

  • Modular SNUSP was tested online here;

  • Reng was tested online here.

Explanation

I was looking at various leads for languages to add. One possibility was to find a language with # line comments that could plausibly be added to the "scripting language" line (which handles Perl, Python 2 and 3, and Ruby). It took me a while to think of an appropriate language that could be syntax-compatible with the ones already there, though.

It turns out that the answer had been staring me in the face for ages. If you click the TIO link above, it'll open up the polyglot test driver, which is written in bash. So all this time, I had a tab saying "Bash — TIO Nexus". You'd have thought that'd be a hint, but apparently I missed it. As a bonus, bash is also a scripting language, so the term "scripting language line" is still appropriate.

The bash program starts in the same place as the other scripting languages. However, there's a fairly simple way to split it away from them; in single-quoted strings, \ is an escape character in most languages, but not in bash. So we can hide bash code from the other languages via '\'…';, which is a degenerate statement (with no effect) in Perl, Python, and Ruby, but executed in bash. echo 50;exit is a fairly simple way to end the bash program. Well, almost.

The biggest problem here is that bash will, upon running exit, continue parsing until the end of the current line (even though it doesn't execute the code in question), so we need to make sure there are no syntax errors on the rest of the line. We have a ' just after exit; that isn't (and cannot be) immediately matched. Later on on the line, '…' is used to hide some Brain-Flak code from the scripting languages, but that would unhide it from bash. As a result, we need to change what sort of string literal we're using to hide the code, going from single-quoted to double-quoted strings. or"'" does the trick without disturbing Perl, Python, or Ruby (as the left-hand argument is truthy in every case).

We now have an unmatched double quote that extends onto a future line. It was fairly hard to close it without disturbing at least one other language; what we actually do is to change the way we hide code from bash from double quote back to an unmatched single quote in a Python/Ruby comment on the subsequent line, and finally close the single quote at the end of the line after that.

Pyth and 05AB1E

Messing around with double quotes also disturbs the languages that were using double-quoted strings to hide code, Pyth and 05AB1E. The main trick we use here is to ensure that every double quote we add has another double quote soon afterwards in order to expose as little code as possible. (This explains the extra double quote on the __DATA__ line, which isn't necessary for bash.) Pyth uses \ as an escape character; the main upshot of this is that it limited the scope I had for messing around with strings in the scripting languages, forcing me to use the rather convoluted method above (as I couldn't easily make use of the difference in \ behaviour between bash and everything else). In 05AB1E, ' acts as an escape character outside strings, and having it escape the leading " wouldn't do. So I ended up needing to place a useless padding character (defaulting to my usual x; it makes things easier to read!) inside the "'" constructs that are used to change between bash quoting styles.

Prelude

By far the hardest language to fix here. The problem is that the scripting line, with all its parentheses, was moved sideways, and thus the Prelude control flow (which cares a lot about the way in which parentheses are vertically aligned) was completely destroyed. I thus had to try to reconstruct something that works.

Worse, the current first line (which I really didn't want to rewrite) places something of a hard limit on where the parentheses can appear. It starts off with a nonzero digit (two of them, in fact!), and is soon followed by an opening parenthesis. That's a loop in Prelude, and loops early on in the control flow in Prelude cause a number of different issues (mostly because they cause more code to run, rather than less). As such, I badly needed to open a 0-iteration loop on some other line in order to skip over that code. The main line for the C program is highly suitable, but we need to be very careful with where the matching closing bracket is; too far right and the unmatched bracket on the #R+ line will cause trouble, too far left and it won't comment out enough code. (Bear in mind that an opening parenthesis on one line can match a closing parenthesis o a different line.)

Once that's done, we have just enough space to stick in an opening parenthesis on the Incident line, and we've finally got safely past the first few characters of the program. However, the difference in parenthesis placements ends up meaning that some of the Incident/Whirl code actually runs in Prelude, corrupting the stack. Instead of trying to prevent this, I moved some of Whirl's zeroes further to the right, allowing them to give us a working Prelude program again.

One other small change was on the first line of the program; the final parenthesis of the line was in a position that was very hard to avoid. I added an extra c just after the Pyth code to shift it to the right. (Many languages are parsing that point of the program, so it took a surprising amount of trial and error to find a padding character that wouldn't break at least one language!)

Incident

Prelude was hard enough by itself, but getting Prelude and Incident working at the same time was nightmarish. Prelude placed a lot of constraints on the code which prevented me freely moving things around, and thus made accidental token construction harder to golf out. For example, Prelude only really needs one 0 moved out to the right, but that caused 00 to become a failed token, breaking some of the tokens we wanted as part of the Incident program (because if two tokens overlap, they're both rejected, and the 00 was overlapping a token we wanted in addition to overlapping itself). I had to move both out to make a fourth copy and prevent it being even considered as a token.

More subtle are the tokens ;' and ␠␠ (i.e. two space characters). The issue is that these both appear before the kG that is being used to jump to the start of the program, and thus will break Incident's control flow (in addition to breaking the program's centre point).

Removing a copy of ␠␠ by breaking it up doesn't seem viable. Removing it via overlapping it might be possible (␠= is a promising potential overlap), but it's almost certainly less verbose to just add a fourth copy, which is what I did here.

Meanwhile, we can use a different trick for ;'. Breaking it up isn't something I wanted to try, given that it's used in fairly spacing-sensitive situations. However, it's not that near the start of the program (despite appearing on the first line), so it's plausible that we could jump over it (thus causing it to not affect control flow) rather than needing it to not exist. I looked for a suitable token to use for the jump which wouldn't screw up any of the other languages. /v appears a little earlier on the first line, and doesn't break anything, and thus that's what I used.

50 languages in 1 Kib of code

It was pointed out by @MistahFiggins that my 1025-byte submission would be way neater if it were 1024 bytes (especially as the fiftieth language is a milestone in its own right). This required finding a byte of savings somewhere. In this case, I saved three bytes in the Deadfish~, at the costs of two extra bytes used to make Incident tokens line up correctly, and thus bringing the program down to 1024 bytes exactly.

Previously, the formula that the Deadfish~ code used was (2²+2)²+10×1+2 = 48. The new formula is (3²-2)²-1, also producing 48. Surprisingly, it isn't that much shorter to write in Deadfish~, despite being considerably simpler.

This also gives us a VIP score of .008192. Not only is this a new record, it's also a nicely round number in its own right (which is, obviously, a consequence of having nice round numbers as the inputs to the formula).

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

2Sorry for not having a TIO >_> (Sincerely, creator of Reng) – Conor O'Brien – 2017-03-21T03:46:58.830

@ConorO'Brien Ping Dennis? Also, ais523, you should try to golf a single byte off ;) – Mistah Figgins – 2017-03-21T03:50:53.400

1You can cut the space in puts(z ) if you swap ( and P in line 2, thanks you the prelude leeway you've created. Bravo on this answer. #50in1k – Chance – 2017-03-21T04:41:25.383

1As it happens, I golfed off a different byte. Now it's at 1024 exactly I don't really want to change it :-) Perhaps a later answer can save some of the savings we have; there are likely a lot more (e.g. there's likely old Incident padding/detokenisation lying around that's no longer needed). – None – 2017-03-21T04:46:52.303

6@ais523 agreed. This answer was always meant to be 1024 bytes. – Chance – 2017-03-21T04:47:50.463

Now all we need to add is malbolge. – TheNumberOne – 2017-03-23T01:50:22.587

I was thinking about bash for ages but didn't think of this. Why doesn't '\' output an error in bash (bash: \: command not found or similar?) – Muzer – 2017-04-05T15:32:16.673

Ah, turns out the answer is that it DOES output an error... – Muzer – 2017-04-05T16:35:30.883

@Muzer: It's a warning, bash can keep running despite the command not existing. Warnings are generally considered irrelevant on PPCG. – None – 2017-04-06T12:57:23.623

@ais523 It's definitely an error, it's just that bash ignores errors by default. I might try and fix it if I think of another language. – Muzer – 2017-04-06T13:21:04.970

(It's an error in that a command run by bash exits with an error state... not that it stops the script running. It's similar to PHP/etc. which also ignores errors where possible, IMHO) – Muzer – 2017-04-06T13:45:52.313

30

37. C++ (gcc), 776 bytes

#  1"16" 2//v\(;@#/;n4"14"
#/*`3 auaaZ<>16/"<"6/b.q@")(22)S#  ␉␉␉␉ 
#yy␉;36!@
# ␉
#=␉>
#[#yy#yy0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#`<`␉|
print((eval("1\x2f2")and( 9 )or(13 ))-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"*␉
""""#//
=begin␉//
#*/
#include<iostream>␉
int main()  /*/
#()"`#"\'*/{std::cout<<37;}/*'"`"
$'main'␉//
#-3o4o#$$$
<>3N.<>␉//
#xx
#x%~~~+␉+~*ttt*.x
#xx
=end   #//
"""#"#//
#0]#echo 21#/(\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE)  ap
#_~nJ|#o51\   
#0␛dggi2␛`␉|1|6$//''25  >>>>>#>27.say# =#print(17)#^_^_7LEintndus({})!<>+]/*///Z222999/3!@"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 them online!

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required.

I added another format to the test driver output that escapes double quotes as well as make line feed replacements. This is so I can feed the single line string to a c(gcc) program I wrapped around the function created by @feersum here. Hopefully others can make use of it as is.

Here's the Incident token program. Ideally I'd like to deliminate the tokens since they are a bit hard to read, indicate the "center" token, and include it in the test driver. But I don't really know how to do anything other than make various programs print sequential integers, so this is as far as I've gotten.

I've attempted to solve the obvious Incident problems, like tokens after the beginning and end jump tokens and anything that looked extraneous, but I haven't balanced the tokens to put 0o at the center. I'm not really sure what the logic is exactly to determine the center. I'm hoping @ais523 will help there. This string near the end 7LEintndus({})!<>+ would all be tokens if not for this 4th inclusion in the code. These can all be removed (and replaced with a . for Hexagony alignment) in order to adjust the center token.

I'm going to be updating this post off and on over the next day or two to walk through the code, (assuming Incident can be verified/fixed without going over the byte count). But it's super late now, and I mostly wanted to get this out there before I had to solve another Labyrinth like problem. :P

Explanation

How the C++ code works.

I think most people are familiar enough with C++, so I won’t go into too much detail. Block comments come in the form of /* comment */. Line comments come in the form of //comment. The actual code utilized by C++ to produce the answer is int main() {std::cout<<37;}. And the library that’s used to interface with STDOUT is referenced by this statement #include<iostream>.

/*Comments Abuse*/

For me, the story of C++ goes back to my Brain-Flak answer.

After finally finding #28, I set out to study some other polyglots posted in PPGC and all that studying led me to a few easy answers (most of these are still available to be found if anyone else is so inclined). But more importantly, I came to a conclusion about polyglots in general: large polyglots tend to fall into one of two broad categories: # comment abuse or /* comment abuse.

This is not a fact or restriction in anyway, but of a personal mental framework that guided my next several answers.

From here I reasoned that if this was to become the world’s largest polyglot, which I presume it to be currently, it would be best if it could leverage comment abuse from both comment families. So I set out to find a way incorporate a /* comment language and pushed towards the C family due mostly to a personal familiarity.

C++ Initial Test

My initial thought process for this was to use C# mostly because of my familiarity and the first hurdle for C# was getting the polyglot into a state where it could accept a line that didn’t start with # without otherwise being treated as code by the scripting languages. The Rail answer, along with several byte inflating answers that lead up to it, solved this piece.

Next came the problem of how to initiate the first /* comment block. I knew the line would have to start the line with a # to remain invisible to Perl, Ruby and Python, but whatever came before the /* would be read by C#. I attempted a C# #region tag at first, but that turned out to be too ridged for the 2D languages. Enter C++.

C++ has several preprocessor directives that all start with #, which give a lot of options for the 2D languages to traverse. But it turned out that all of them were incompatible with at least one language, and being in a C++ exposed code space, I had limited workarounds. Out of frustration and desperation, I stumbled into the fact that C++ would simply accept just a single # before the comment block. Okay, whatever, that’s workable. So I moved forward with the presumption that #/* could work as the first three characters in the polyglot.

The second piece of basic verification was to ensure that the actual print statement could live happily with the other codes. I knew from the Brain-Flak answer that Japt didn’t like un-escaped {’s and that was needed for C++ to say int main() {std::cout<<37;} and C++ wouldn’t allow Japt’s escape character in the middle of its code. This time I was lucky enough to find that if I dropped out of Japt’s literal string just for this statement, Japt would still happily produce the same result.

Meanwhile, Brain-Flak didn’t like the {} either, but I was again lucky to find that C++ was ok with a # between its int main() and {std::cout<<37;} statements, allowing the curly braces to be commented out of Brain-Flak’s perspective.

So, with the main problems of C++ proven to be theoretically solvable, I began the arduous process of resolving all the errors I’d introduced.

2D Landscape

The hardest part of this answer was by far the reconfiguration of the top two lines of the polyglot. And the most significant problem was the *. Underload will not allow a * prior to a (. It considers this as math operation on an empty stack, which it feels is an error. So the polyglot required a ( prior to the /* but C++ couldn’t allow this. So the solution was to us a C++ line comment // on the first line to hide a ( and then start the second line with a #/*.

Next, Befunge really didn’t like the idea of a / without something being divided but after studying the existing Begunge answer of 16/"<"6/b.q@ I stumbled on the idea of a number and a string smashed together ahead of the //. It worked and I have no idea why C++ is ok with this but it accepts # 1"16" 2 as it’s opening statement. I’m not going to question it, but I do know that the spaces are required for it to work.

Line One

Japt turned out to be rather space sensitive and didn’t really want to enter into its backtick based string on the top line, so it and Pip’s backtick got moved to the second line, forcing a lot of linguistic gymnastics on line 1.

  • Pip didn’t like most of line 1, so a second space was placed after the first #to indicate a comment.
  • The ( for Underload had to be escaped out of Japt with a preceding \.
  • # is a jump terminator in Turtlèd so it was required, but Pyth considers this a error terminating loop, so Pyth needed a divide by null / after the #
  • I’m not sure what the @ in the first line is doing anymore, but Pyth and Japt seem to like it’s presence better than not, although @ is not a meaningful character according to Pyth’s documentation.
  • And it looks like the first ; can be removed at this point without consequence, so I’m not sure what was being solved there anymore, although I suspect it was Pyth related. But it looks like future solutions can save a byte by omitting that one.
  • <>< and Turtlèd both basicly work the same as before wiht <>< reflecting on the first # and wrapping to the end of line one. And Turtlèd jumps with # like I mentioned and ends with the "14" string which it prints.

2D routing

With these issues resolved, the next phase was routing the 2D languages. Previously the initial v was ignored by the Befunges due to the preceding #, but sent Haystack and Minkolang down. Now, the initial space attempts to send Minkolang along the 3rd dimension, which its documentation refers to as the time dimension.

Quick aside on Minolang’s 3rd dimension: to me it’s something of a misnomer to call this a time dimension it really seems more spacial than temporal to me. I didn’t really get it until I found this link that illustrates the concept, and it seems more like the multiple layers of a 3D chess board. My belief is that this is how 3D languages generally operate. But as this was a new concept to me, I thought I’d throw this info out for others.

So Minkolang’s multiple layers are delimited by lines ending in $$$ which I threw onto the end of the Rail code here: #-3o4o#$$$. Now, Minkolang hits the space and falls to first > in <>3N.<> ␉// and proceeds to the right outputting 3. #>couldn’t be allowed to start this line because it would attempt to terminate a Perl6 comment block, so < is used instead of # to balance for SMBF and Brain-Flak. However, this is a Brain-Flak stack swap procedure, so a second set of <> is used after Minkolang Terminates in order to swap back to Brain-Flak’s correct answer.

Labrynth similarly bumps up against the space but it causes Labrynth to moves down in column 1. It then turns down line 2 where it travels down to the 3 hits another wall, causing it to turn south again and hit a ; which causes the 3 to get popped. Then the program continues to the right where 36 gets stored and printed, before finally finding a @ exit. This path is longer than it needs to be, but I found that Prelude would output a nul byte before it’s normal 20 output if the ! was any further to the left than it is now, regardless of the line it appears. So I made it more correct, because I had the space to do so.

Next, Haystack’s routing got changed because / now comes prior to v on line 1 and reflects its path up like Reng. Fortunately, Reng is a cohabitates rather peacefully. The one hitch was that Haystack’s needle | was a reflector in Reng, so a Reng uses a Befunge like jump (#) over the needle to conclude Reng correctly.

The Befunges continue along line 1 until the v and get directed down and then to the right on the second line to conclude with the same code used before. My sense is that this piece can be golfed down a bit now that fewer languages are attempting to meaningfully traverse the code, but I didn’t need any more walls to bang my head against, so I left it as is.

Finally, Cardinal’s starting point is % which had not particular need to be lumped in to the already dense top two lines. So I moved it down to Python’s string. Its multiple code paths are also now bounded by x’s, which ends the movement of its pointer.

Line 2 &3

The only significant change here is that all of the : got golfed out for one reason or another. Maybe Prelude’s ( needs or maybe it was simple byte count problems – probably both. The other thing is that trigger’s jump code got moved back and rebranded as auaaZ. I had space to fill to meet Befunge’s code path and this seemed best. Also the < following this piece is to balance SMBF’s following >. Finially, the lone near the end of the second line are to maintain 05AB1E’s string. Also, yy on line 3 are just filler characters for Labyrinth.

The Big String Esolangs

With the top two lines resolved, it was time to start digging into the fuller-parsing esolangs, and Pip turned out to have a problem. If you remember we dealt with the curly braces in {std::cout<<37;} by dropping out of the Japt string to let Japt treat this as code. Well, Pip is using the same string syntax and didn’t like this line as code and Pip has very similar string declaration options as Japt. Both use a single ' to declare a one character string, both use the same escape declaration of \ and both will accept " as string identifiers. So it was difficult to make Pip believe this was a string without making Japt believe the same.

It turned out that Japt did have one exploitable difference though - # takes the ascii value of the next character. So, #"` will terminate the Japt/pip string, then tell Japt to take the asci value of ", while telling Pip to start a new string. The " probably could have been a backtick instead, and probably would have been better, but my line of thinking was to use a different string identifier on the inside as another point of string manipulation. So here’s another place where you could save a few bytes down the road.

Next, I had to initiate the Japt string after the curly braces while allowing Pip to remain in a string. I did this with '"` that's a single quote, double quote, and a backtick. For Japt the ' is not in a string and is therefore an indicator to take the next character as a single char string. Pip sees the ' as part of the string and terminates its string with the ". And finally, ` is indicates to both Pip and Japt that another string is beginning which continues throughout the polyglot until the last line where both languages complete happily.

Now, both Japt and Pip worked at this point, but 05AB1E failed because of the use of " caused some error inducing code exposure. Fortunately this one was easy enough to solve by putting another set of " around the whole thing, leaving the set of string manipulations as "`#"\\'*/{std::cout<<37;}/*'"`".

Finally, with the line now looking like this,int main() #/*"`#"\'*/{std::cout<<37;}/*'"`" which Underload had a problem with. The consecutive *’s, were another syntax error so I threw a () in the middle of the *’s to appease it.

The Fragile Esolangs

The big hurdle now was White Space. I won’t go into a ton of detail here because most of the Whitespace solution is built into the explanations already given, and I just glossed over the instances where whitespace forced a few decisions. I’m looking at you Labyrinth. The big change though, is that the actual code to output Whitespace’s answer is on line 2-4 instead of 1-3. This is largely due to Japt’s code exposure in line 1.

Thutu originally had problems with what had been this line: int main() #/*()"`#"\'*/{std::cout<<37;}/*'"`". So, I threw in a linefeed just before the first # to hide all the problems behind a comment indicator and then spammed out a bunch of trailing /’s everywhere else that was code exposed.

At this point I aligned Hexagony and found new problem. The code at the very beginning, which started life as # 1"16" 1 made the + in /+23!@ no longer clear the stack. So, I just removed the + is and found it now output 123. This was easy enough to fix by changing the opening gambit to # 1"16" 2 and golfing the Hexagony piece down to /3!@.

Whirl had some changes, but it was mostly a matter of making sure the right number of leading 1s appeared before the Whirl-Incident line. Incident though had one token that was particularly difficult. I had exactly 3 copies of /* and */.

I initially wanted to just throw *//* any old place in the code to create a 4th copy of each, but Underload saw consecutive *’s again, which was a no go. Ultimately I threw a / on the end of this line int main() /* to make it end in /*/, thinking that I’d make the tokens overlap, but I only succeeded in creating 4 copies of one of the two tokens. Right, right. That’s how that works. Oh well, I’ll just throw a similar / in the final */ to make a 4th there. After this, I replaced a bunch of hexagony no-ops with a 4th copy of several incident tokens in this string on the final line7LEintndus({})!<>+.

Conclusion

Ok, that's all the detail I have for this massive refactor. I promise not to have so much to write about next time. I actually have no idea if C++ is a good or bad choice for this polyglot, but my sense it opens some options. Hopefully this leads to good things.

Happy coding.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

2Looks like g++ requires a .cpp, so I added that to the file extension specific section. Then just had to use run-wrapper.sh to handle it. I'll edit it in. – SnoringFrog – 2017-01-30T15:55:26.540

If I'm following the Incident correctly, looks like another token that has all 3 occurrences after the second 0o would fix it. Currently, #xx, #0, and p appear twice. Can one of the a's at the end of the 3rd to last line be replaced with a p? – SnoringFrog – 2017-01-30T16:49:03.097

@SnoringFrog Yeah, that looks do-able. I'll update the post. – Chance – 2017-01-30T16:59:26.480

1

I want to add symbolic brainfuck to this as it's an easy addition, but unicode characters crash python2 - _ -

– SnoringFrog – 2017-01-31T01:49:24.317

1

@SnoringFrog I feel the same way about emoji

– Chance – 2017-01-31T02:20:30.420

"Middle token" in Incident is defined as the token which has the same number of tokens before it and after it (or if there's an even number of tokens, one more after than before, as an exact tie is impossible then). C is one of the languages I was considering adding; I'm not sure what the purpose of a null directive (# on a line by itself) is meant to be, but they're defined in the standard, so we can expect them to work. – None – 2017-02-01T00:24:28.380

1Also, ** isn't a syntax error in Underload; it just consumes a lot of stack, which I assume wasn't available at the time (likely because you golfed out the colons). You can top up the stack with parenthesized groups or colons before or between them, or sometimes hide the code from Underload by parenthesizing it. – None – 2017-02-01T00:40:19.540

@ais523 Aweome. Thanks for the clarifications. – Chance – 2017-02-01T01:30:07.487

1@ais523 In the very early days of C, to save time in cases where it was unnecessary, the preprocessor wasn't run unless the first line started with a #. But if you didn't want your first line to be a preprocessor statement, you would therefore need a way of having the first line start with a # without having it actually do anything, so you had the null directive. I strongly suspect backwards compatibility with code that used this was the rationale for its inclusion in the standard. – Muzer – 2017-02-01T10:42:12.887

Anyone who works Java into this earns every internet point – Pavel – 2017-02-01T15:27:38.133

27

5. Python 2 (35 bytes)

#3N.;n4
print('1'if 1/2else'5')
#i2

This program prints 1 in Python 3, 2 in Vim, 3 in Minkolang v0.15, 4 in ><> and 5 in Python 2.

Try It Online beta!

In Python 2, 1/2 is 0, which is a falsy value, which makes Python print 5. In Python 3, 1/2 is 0.5, which is a truthy value, which makes Python print 1.

betseg

Posted 2016-12-06T18:59:02.963

Reputation: 7 258

I can confirm it works in Minkolang – Cows quack – 2016-12-06T19:43:48.307

print('1'if 1/2else'5') breaks on my system without a space between 1/2 and else – Tasos Papastylianou – 2016-12-08T08:58:45.787

Well, it works with both versions on TIO. – betseg – 2016-12-08T09:01:01.210

25

28. Brain-Flak, 280 bytes

#v`16/"<"6/b.q@"(::):::   (22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++~~~%
#=~nJ<R"12";
#[
#`<`|
print((eval("1\x2f2")and (9) or (13))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{}\/^23!@[()])}\{})(\{}\{})'#@46(8+9+9+9+9+=!)=#print(17)#]#echo 21#|/=1/24=x=90/
#8␛dggi2␛` |1|6$//''25  #>say 27#"26

␛ represents a literal ESC character, as usual.

This program prints 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 (tested here), 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 Vim/V, 1 in Python 3

First off, I want to say what a privilege it is to be able to contribute to this challenge. I only heard of code golf a few weeks ago and I have been absolutely hooked ever since. The first thing I did when I found this challenge was try to run the code as is in various languages just to see if I could find anything I could work with. This was back when we were on like #6. I honestly thought this challenge was bonkers impossible, but here we are (#28 Wow!). What I found at the time was that Brain-Flak output the value 2. So I set out to learn it.

Brain-Flak turned out to be pretty great for this kind of challenge because it's fairly easy to learn and it ignores pretty much any characters except (){}[]<>. # also happens comment anything after it on the same line, so the only part of the last submission that was ever considered for Brain-Flak was print((eval("1\x2f2")and 9 or 13)-(0and 4)^1<<65>>62) which then paired down to ((())()<<>>). So then the plan became adding superfluous parenthesis to what I've come to think of as the python code.

I modified the python bits to parse in Brain-Flak to ((() () ())()()<<()>>) which equates to 2 stacks the first being 5 and the second being 3. After that I'm squaring the 5 with ({({})({}[()])}{}) and adding the result to 3 with ({}{}). This squaring and adding is going on in a string from a Python perspective. I can't claim to understand Python's reasoning here, but I am fairly confident that this string isn't otherwise being evaluated by other languages in a meaningful way, with only a couple exceptions.

Japt, it turns out, interprets curly braces within a string as containing code, but these were easy enough to escape out with \ before each { in this string. But this bloated up the byte count. Such is life.

Prelude was pretty forgiving with all of my Parenthesis's. An earlier comment pointed that Prelude would have fits with vertically aligned Parenthesis's and I happened to only create one. Sweet! The ( in the top line lined up with the and (9 in the big line. So I had to add an additional space before the ( in the top line. My assumption here is that the double space was a comment indicator for something, so adding an additional space seemed trivial, and it worked. I should point out that I tried adding a additional spaces in the (9) instead, but Cardinal didn't cooperate.

05AB1E didn't like my first attempt at the Python string being encapsulated in double quotes, but everyone seemed agreeable to using single quotes. Not a big deal there.

Hexagony was the only language left at this point, and I was obviously way past the next hex size threshold, so it was time to get dirty. The /^23!@ is the Hexagony code and I'm super excited about it, because I think it'll make future additions much easier. This little piece can basically be moved anywhere in the python string without busting any code. This is the full string just so we're all on the same page '(\{(\{})(\{}\/^23!@[()])}\{})(\{}\{})'. The / here sets the path of Hexagony from SE ->NW to W-> E down this string, which we have a lot of leeway with. (The preceding \ is to escape / for thutu BTW). My idea here is if you make changes, odds are that you'll end up going through this string at some point and you can slide the Hexagony piece around within the string to catch the code path and send it to the proper conclusion. Just take care not to come between Japt's \ and the {. If you have trouble with this, the @ to the right of the string is just left over from another Hexagony solution, and can be removed without consequence to the other languages. And of course if you happen to catch Hexagony's code path going the opposite direction, you can of course use @!32^\ instead of /^23!@. Also, you may notice that my solution removed the ===2 from the code to keep things under the byte limit. Someone mentioned in here that this was for Hexagony's alignment and I didn't need it anymore.

Finially, here is a little piece of code I found while exploring codegolf that converts a line of text into a Hexagony readable hexagon so you can debug. I'm sure plenty of people know about this, but I hadn't seen it posted here, so it might help someone else too. Fair warning, you have to alter the input to remove the backticks and carriage returns as well as swap the literal escape for something that takes up normal amount of space to get the code to line things up in a pretty Hexagon.

P.S. While I was writing this out, I realized I had a mistake. I had believed I was clearing Hexagony's memory edge for with the ^, but apparently I can replace it with a no-op to no consequence. That ^ should probably be a + if you try to manipulate this section. I was apparently passing through a + prior to this, but future polyglotters may not be so lucky.

Good Luck!

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

I was waiting for the rundown and explanation before voting, but the rundown looks good, so I'll vote while waiting for the explanation :-). I assume that all the extra backslashes are to avoid a syntax error in Thutu? Also, interesting approach for where you added your code, which I'm guessing has something to do with Hexagony. It'll be nice to see the full explanation. (Also, welcome to PPCG!) – None – 2016-12-28T04:39:18.083

And now I see the explanation; I enjoyed reading it. The "Python code" is actually used by several scripting languages (Python, Perl 5, Ruby), but they all interpret and and or the same way, so your method of commenting the code out in the scripting languages but not Brain-Flak happens to work in all of them. – None – 2016-12-28T08:17:17.227

Thanks @ais523. You mentioned the placement of my code. So, I knew I had to place the brain-flak operators somewhere that was visible to the scripting languages and my initial, incorrect assumption was that it would be easiest on a new line. This didn't work for Retina and I didn't want to deal with both it and the 2D language problems I'd create trying to fix Retina, if possible. I was lucky to stumble into the current placement. – Chance – 2016-12-28T16:21:41.337

1Fantastic answer, and a very thorough explanation! I'm really happy to hear that you enjoy brain-flak. :D – DJMcMayhem – 2017-01-02T18:59:20.540

23

3. Minkolang v0.15 (26 bytes)

#>>>>>>>>v
print(1)#>3N.i2

This program prints 1 in Python 3, 2 in Vim, and 3 in Minkolang v0.15

I hope I don't mess things up by introducing a 2d language

Try it online!

Explanation

#                     stops program from moving through time (really does nothing)
 >>>>>>>>             I can't use a space because then the program will move through time
         v            go down
         >            go right
          3N.         Outputs 3 and end program
                      Anything afterward is ignored since program has ended

Vim somehow ignores Minkolang, so that's good

And there really wasn't a problem with Python since it ignores the comments #

Next...

For the next language, I suggest something like ><> since # acts as a reflector (so that the direction will change to left and it will wrap to all the way in the right) so you can add code that can be ignored by other languages

Cows quack

Posted 2016-12-06T18:59:02.963

Reputation: 12 883

8“move through time” wat? – TuxCopter – 2016-12-06T19:27:45.050

3@TùxCräftîñg Minkolang has 3 dimensions (2d = normal, the 3rd one is time). TBH, I don't understand it, it just states that in the explanation on the TIO link – Cows quack – 2016-12-06T19:28:51.953

@mbomb007 What exactly are you referring to? – Cows quack – 2016-12-06T19:35:22.993

@mbomb007 4th submission (><>) already posted :) – Cows quack – 2016-12-06T19:38:52.620

@KritixiLithos I posted ><> without even reading you're suggestion. It's such a good choice for this sort of thing – Blue – 2016-12-06T19:39:51.307

@BlueEyedBeast 2d languages are a good addition to polyglots – Cows quack – 2016-12-06T19:42:29.577

Added Befunge in addition to Minkolang :-) – JungHwan Min – 2016-12-07T06:09:58.243

@JHM Now we have 2 more 2d languages added to Befunge :) – Cows quack – 2016-12-07T08:36:42.430

1@TùxCräftîñg I don't think I can do that – Mendeleev – 2017-01-31T20:34:24.920

1@wat Hm this took me way too long to understand – TuxCopter – 2017-01-31T20:55:53.937

23

20. Prelude, 167 bytes

#v`16 "<" 6/b0\ .q@#;n4"14""
#>3N9@15o|R"12"*^*ttt*~++%
#=|
print((1/2and 9 or 13)-(0and+4)^1<<65>>62);#35(99999+++++!) =#;print(17)
#       ~nJ<
#
#gg99ddi2` |1|1+6

Literal ESC characters in the same place as in the previous submissions (between the # and g, and between the 2 and `, on the last line), because you can't take Vim out of insert mode with printable characters.

This program prints 20 in Prelude, 19 in Reng (testable here), 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, 8 in Retina, 7 in Japt, 6 in SMBF, 5 in Python 2, 4 in ><>, 3 in Minkolang, 2 in Vim/V, 1 in Python 3, and a partridge in A Pear Tree.

The existing code pretty much cancels itself out in Prelude, consisting only of while loops with falsey arguments and some stack manipulation on stacks we don't care about. Even better, there's a spot in the code that's a comment in all the languages that have them (between the # and =# of the previous submission). The hard part of fitting Prelude into this was generating numbers with only one stack and without blowing up the byte count. This program uses a loop that adds 45 to every stack element and outputs it as ASCII, thus by placing a 5 above a 3 on the stack, we get 20 as output. (Neatly, 20 is an easier number to output than 19 is in Prelude, so answer 19 being posted actually helped me a bit.)

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

Prelude should be fairly easy to work into future programs. Some advice for anyone it may happen to cause trouble to: don't let parentheses line up vertically; make sure you don't allow exclamation marks outside parentheses; and once you've placed digits outside parentheses, don't place more parentheses further right on the same line. The gap which I put the Prelude program into is still open, and looks like it might be a fruitful place for other 1D languages to go (Prelude's sort-of 1½D, and acts more like a 1D language in this program). – None – 2016-12-08T06:53:08.107

Nice, beat me to the punch with Prelude :) I actually think ASCII-only V might be possible with :%s replace, but even then it's a little tricky (and V is annoying to test) – Sp3000 – 2016-12-08T07:24:59.760

If you use a : to start a command in vim, you're gonna need a carriage return, which also happens to be unprintable. :/ – Zwei – 2016-12-08T09:07:44.400

4+10000000000 for a partridge in A Pear Tree. But does it print 5 GOLD in RINGS? – immibis – 2016-12-12T01:32:45.337

23

65. ALGOL 68 (Genie), 1634 bytes

#16  "(}+?23!@)-("//*\Dv;'[af2.q]PkPPX'#CO)"14";n4
#/*0|7//```"`   [-'][!(>77*,;68*,@;'1,@10␉␉11)(22)S␉␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#_>++++.>.}+?
#`<`
#<]}} +<[<.>>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++59L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsd4O6O@oh]>@@+.---@.>][
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_00)
[ "]56p26q[puts 59][exit]" ,'\[' ];#/s\\/;print"24";exit}}__DATA__/
#
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.

#
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>){(<{}(({}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{nd
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( ){puts(p);}/*
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.s
=end
"""#"
#}
#s|o51~nJ;#:p'34'3\=#print (17)#>27.say#]#print(47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm 
# sss8␛dggi2␛`|$// ''25  16*///~-<~-<~-<<<~-XCOprint("65")#s^_^_2229996#

VIP score (Versatile Integer Printer): .005949 (to improve, next entry should be no more than 1710 bytes)

Try it online!

Rundown

This program prints 65 in ALGOL 68, 64 in Agony, 63 in Brian & Chuck, 62 in Grass, 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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 languages can be tested with the test driver above, but 6 languages have to be tested locally.

  • Reng can be tested to output 19 here.

  • Modular SNUSP can be tested to output 31 here.

  • Incident was verified to test 33 via manual balancing of tokens.

  • Deadfish~ can be tested to output 48 locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are n unavoidable consequence of running any Deadfish~ program.

  • Moorhens 2.0 can be tested to output 60 using this interpreter.

ALGOL 68

ALGOL is probably the least known of the four high-level programming languages from the early days of programming - the remaining languages of this nebulous distinction being COBOL, FORTRAN, and Lisp. ALGOL was better known in academic and mathematic circles at the time, but is today best known for its huge influence on modern languages. In fact most modern, practical languages can be described as “Algol-like,” not the least of which is C, which of course has its own lineage of influences and derivatives.

I’m pretty excited to include ALGOL because it’s another major stepping stone in computer history that we get to add to this monument we call a polyglot. That’s cool stuff.

ALGOL68 is the latest of the three major ALGOL specifications, the others being ALGOL60 and ALGOL58. Interestingly, the specification doesn’t have a fixed syntax, meaning that the tokens are defined, but not the spellings. This makes the language highly interpreter dependent because any given interpreter may use a different symbol to initiate a comment block for example. The specification describes the ¢ as initiating a comment block. But because ¢ isn’t among the base 127 ascii codes it understandably doesn’t see much use as the comment indicator among the available interpreters. Well it turns out that the Genie interpreter spells ¢ as #, which is all the opening we need to get past character 1 and make a polyglot.

Genie in fact has three comment syntax options, the other two being co and comment, both of which are specified as being written in bold. Yeah, bold. If we use italics, well that’s a variable. Genie solved that for us again by spelling bold in all caps. And since CO isn’t in the polyglot anywhere, we’ve got an easy method of hiding the polyglot from the parser. If down the road CO is needed for a language, we can switch to the more verbose COMMENT syntax.

There are no line comments in ALGOL - they’re all block style, which means they need to be terminated. Given the initial state of the polyglot, our ALGOL block comment is opened immediately and is terminated near the end of line 1 because Turtlèd is similarly using # as a jump token. Turtlèd very fortunately doesn’t have a problem walking through the C and O characters so in line 1 we can just insert CO immediately after the second # to initiate a fat block comment for ALGOL68.

From here we just have to place COprint("65") somewhere. I chose the last line because I preferred to finish out the line with another # comment and I didn’t want the comment to terminate at the # at the beginning of the last line. So we follow up our ALGOL print statement with #s and a # as the last character in the polyglot. The s in #s is for alphuck to balance out the p in print.

Thanks to @ais523 for opening up the end of the polyglot with answer 59 and making all this possible.

SMBF

We added a different character to the end of the polyglot to terminate ALGOL’s final comment, and SMBF was previously reading the last character for its answer. To remedy this, I had to change SMBF to read the second to last character by changing this code on line 8 [.>-] to this [<.>>-]. This is an SMBF private code block since BF’s MP is at 0 when the loop is initiated.

Trigger

At this point, I noticed some weird behavior with SMBF and it had to do with the relationships between these code segments ad the end of the polyglot.

• Incident’s jump destination: ^_^_

• Trigger’s Jump destination plus answer: X222999

• ALGOL68’s answer: COprint("65")#s

ALGOL’s answer tokenized a couple Incident tokens within its code segment, so ALGOL’s code had to go prior to Incident’s code segment. ALGOL also caused a prelude alignment issue if it went first in the order so it had to go second or third. SMBF meanwhile had an inexplicable failure when Incident’s code went last, so Incident had to go first or second. Well, I realized this was an introductory logic problem that appeared unsolvable, so I set out to make the inexplicable more… plicable.

After walking through SMBF I found that the problem with having ^_^_ at the end was due to Wise. Wise’s code (~-<~-<~-<<<~-) isn’t hidden behind a non-executing loop, unlike most of the polyglot. But there’s no SMBF print codes involved in Wise’s code. It was just changing memory values. It seemed innocuous. So what was the problem then? It was that darn SM in front of the BF.

Wise’s code is changing the characters in the code about to be executed, and can you guess what the ascii value neighbor of ^ is? It’s ]. Wise was putting a SMBF loop terminator at the end of the polyglot, causing SMBF to fall into an infinite loop. That’s bad mojo.

After some thought I took the 0 byte solution to the problem and separated Trigger’s jump destination (X) from its answer (222999) and ended the polyglot thusly: ~-<~-<~-<<<~-XCOprint("65")#s^_^_2229996#. This only works because no character appears consecutively following Trigger’s jump that isn’t Trigger’s answer.

Wrapping up

That's all the major changes this round. I did make a minor change to cut the much discussed c in line 1, but that's it for purely golfing changes.

Good Luck!

Incident Report

#<q>"3"O.s became #<T>"3"O.s because detokenizing T instead of q was more efficient at balancing

<>{ became <>{nd to detokenize nd and {␊

Put a space between }} and + in #<]}} +<[<.>>-]>[ to detokenize }}+ more cheaply.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

22

38. C, 804 bytes

#  1"16" 3//v\(@#/;n4"14"
#/*`3 auaaZ<>16/"<"6/b.q@")(22)S#  ␉␉␉␉ 
#yy␉;36!@
# ␉
#=␉>
#[#yy#yy0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#`<`␉|
print((eval("1\x2f2")and( 9 )or(13 ))-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"*␉
""""#//
=begin␉//
#
#*/␉
#define␉z  sizeof 'c'-1?"38":"37"
#include␉<stdio.h>
int main()  /*/
#()`#`\'*/{puts(z);;}/*'``
$'main'␉//
#-3o4o#$$$
<>3N.<>␉//
#xx
#x%~~~+␉+~*ttt*.x
#xx
=end   #//
"""#"#//
#0]#echo 21#/(\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE)  ap
#_~nJ|#o51\   
#0␛dggi2␛`␉|1|6$//''25  >>>#>27.say# =#print(17)#^_^_7LEintndus({})!<>+]/*///Z222999/(3!@)"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 them online!

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required.

Here is my slightly tweaked version of the Incident tokeniser, designed to be a bit less golfed but a bit more useful.

Explanation

I've always loved making little polyglots but never one as big as this; I thought I should probably give it a go!

After @Chance's wonderful C++ answer, C seemed the next logical choice, and given (compared to some previous answers) the relative ease of adding it, I decided to go for it when I had the chance!

I used a very well-known trick to tell the difference between C and C++; the sizeof a character constant is 1 byte in C++ but the sizeof an int (guaranteed to be at least 16 bits) in C. This code should be very portable (except maybe for systems that use bytes with enough bits to fit an int) unless I've made a stupid mistake.

I firstly tried to do a printf with everything inline, but the multiple brackets seemed to be causing issues for Japt, so I made the line simpler, which appeared to fix it.

Next, Cardinal didn't like it, I guessed because of the % in the printf, so I had to solve that one by switching to manipulating strings.

My next attempt, trying to assign a string then change the second byte contingent on the C behaviour, ended up far too long and would have pushed Hexagony onto the next size; I wanted to avoid redoing that by keeping it within the extra characters I had to play with! I needed every byte I could get for this, so I implemented the byte-saving changes suggested by @Chance.

So I golfed that C code down a bit and came up with puts(sizeof'c'-1?"38":"37"); which almost worked, except that Underload was segfaulting, presumably because of the complex expression in the brackets.

Even after removing the extra >> that used to be required to match the << in Perl6, I couldn't get a concise enough way to split out the more complex part of it into a char array assignment. So I ended up looking at using the preprocessor instead.

After a lot of trial and error I found a solution that Retina seemed to like. Prelude which was causing me problems on-and-off all the way through, ended up fixing itself before I got round to looking at why it was breaking (I guess either the brackets or the ! I had in the ternary at one stage, looking at previous answers).

All the while I was patching up the whitespace to get something that Whitespace would like; I found that to be rather easy. Specifically, tab space space space was a very useful combination (the instruction to add the top two items on the stack), since it meant I could add whitespace to lines with no other whitespace without having everything go out of sync (I'm guessing its position in the program means it never actually gets executed so I'm not worried about stack underflows here).

I've now tested Incident, and it works! Many thanks to @Chance and @LliwTelracs, which I've just realised is NOT a Welsh name, for helping me get to grips with it. See this syntax highlighting. I have removed the ; token that was appearing before the #yy token. I did this by simply adding an extra ; after the gets statement (my previous attempt involved replacing s (which now appears much more in the C program than it did in the previous one) in the "detokenising" string with a ;, but it turned out I was actually a character short for Hexagony (thanks @Chance), so after attempts to add an extra character to this last line failed, I just changed it back and added the extra semicolon elsewhere).

I have also tweaked the whitespace a little to change some other tokens to make some attempt at centring, to re-tokenise Tab Linefeed (by moving the tab at the end of the #include line to in the middle, thus making three tokens), and to de-tokenise the triple-space token by moving one space in the define line.

Finally, a day after initial submission, I decided to get to the bottom of the scary preprocessor warning that gcc produced (and which made Clang fail). I determined that the reason the first line worked at all is because it's the output from the preprocessor that provides debug info like original filenames and line numberings. They didn't like the first "2" on the first line, because this meant "returning from an included file into the given file", and obviously that's impossible given there haven't been any included files. After changing it to a "1" (start normal header) made a few too many languages choke, I changed it to a "3" (start internal component header), which broke only Hexagony, since it was now relying on the 2. So at the start of the Hexagony code I added an open bracket ( to decrement the 3 to a 2, then a close bracket ) after the end (@) of the hexagony code to satisfy Retina, Prelude and Underload which all expected matching brackets. Re-testing Reng and Modular SNUSP produced no issues, and the Incident tokens looked right, so I had now fixed it! I've tested it on a variety of exotic architectures and it appears to work. I know it's not important for a code golf, and I won't mind if future submitters have to break this again to keep within a byte count or whatever (or if anyone's already started based on this solution and doesn't want to change theirs too much), but there is one good reason I've done this - TIO's Objective-C compiler only supports Clang, so this'll be very useful if anyone wants to add that!

Bear in mind I've never used most of these languages, I hope my success encourages more newcomers to give this a try!

Muzer

Posted 2016-12-06T18:59:02.963

Reputation: 383

@LliwTelracs Huh, the C program linked by Chance in his answer had a different output for the list of tokens: ;#yy;#yy#yy0l0m1k1k0l0i0j0h0h1d0e0b0b0o1d0b0e0e1d0i0f0g0n0n0o0n0c0c0o0f0c0g0g0f0h0j0j0i1k0m0m0l^()z z()()z; ^^_ – Muzer – 2017-02-01T16:49:15.103

The error was that I was copy pasting the value to my program so it couldn't recognize the tabs or escapes – fəˈnɛtɪk – 2017-02-01T17:25:45.703

@LliwTelracs Just trying to figure out the tokenisation myself, it looks like I've now got a semicolon appearing three times. I could add an extra one except that I don't think I can spare the byte as that'll misalign Hexagony. Hmm... – Muzer – 2017-02-01T17:57:44.347

@LliwTelracs I've now figured out how to get rid of that semicolon token without using an extra byte (I somehow missed the bit about the detokenising string at the bottom which I could modify; very useful!). I don't know if the centre token is right, but I hope so! – Muzer – 2017-02-01T18:14:09.557

the Stack overflow treatment of spaces made me take a while looking for why my code was getting 3 spaces in a row as a token but the C program was not. – fəˈnɛtɪk – 2017-02-01T18:29:01.453

@muzer Ignoring the incident jump tokens and the actual incident code, my solution was balanced with one token on the left ␉␊ and 8 on the right p()␉␊␉␊()()pp. The token's here being ␉␊, p, and (). Yours has none on the left and 9 on the right: ()z␠␠␠z()()z␠␠␠␠␠␠ with the tokens being (), z, and ␠␠␠. I believe as long as the number of right tokens minus left tokens = 7 then everything is balanced. I'd try eliminating the triple space as a token then create a token weighted once on the left and twice on the right. Maybe there's one available in the detokenizing string? – Chance – 2017-02-01T18:49:19.803

@Chance Thanks for that! I just made a less golfed more useful version of the C program, and with its help I think I've managed to sort out Incident in this. I will try to test it when I get home (archive.org is blocked on the train and esolangs wiki appears to be down). – Muzer – 2017-02-01T19:49:23.360

I noticed one more thing. Hexagony is outputting a couple trailing nul bytes because it's alignment is one space left of where it wants to be. Throwing in another character anywhere before /3!@ will fix it. – Chance – 2017-02-01T20:05:15.340

@Chance Oops! Cheers, dunno how I missed that. Trying to add an extra character to the detokenising string in last line seems to make Prelude go insane, so I'm replacing the semicolon back with an s, and adding an extra semicolon after the "gets" statement. – Muzer – 2017-02-01T20:50:03.403

1Incident works! – Muzer – 2017-02-01T21:13:12.987

1

@Chance I've just been looking at how that first line is valid in the C Preprocessor, it looks like it's the output from the Preprocessor used for debug info etc. It means "now returning (2) to file with name "16" line 1". I think it's the 2 that makes Clang choke (and gcc warn) since it never went into any files in the first place, so there's nothing to return from. When I get the chance I might experiment with changing it to something else to make it compile in Clang too. See https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html#Preprocessor-Output

– Muzer – 2017-02-02T12:07:22.897

@Muzer Cool! Thanks. I love how much out of the norm stuff I'm learning from this project. – Chance – 2017-02-02T17:05:08.797

@Chance Just fixed compilation in Clang. I discovered a potential future use for this is Objective-C, since TIO only supports Clang for that language. – Muzer – 2017-02-02T17:57:58.633

22

100. brainbool, 2953 bytes

#16  "?63(o?23!*# #@"/*\DZZCv;'[af2.q]PkPPX)\('#CO"14"; */
#/*0|7//```"`  [>.>.])[-'][(>77*;,68*,@,1',;# l1011)(22)S\4n;iiipsddpsdoh coding:utf8ââââ(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>â
# 36!@â`  e++++++::@ 
#~
#y
#`<`
#<<<#>>]}}+-[.+..]+-+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++q   L+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACs]>@@+.---@.>][
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\   \).>]4O6O@|
#[#[(?2?20l0v01k1kMoOMoOMoOMoO MOO0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0 )0\\
[  "]56p26q[puts 59][exit]" ,'\[999'];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<!\
'(wWWWwWWWWwvwWWwWWWwvwWWWw WWWWWWWWwWW/"78"oo@WWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw              (([5]{})))â\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<*.*\>]xxxxxxxxxxxxx)'# \\
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39;'(******* **********819+*+@[*99[?]*]***|!)'
#\\
""""#\
' ( <><        (          )>  ){ ({}[()]  )}{\';      a=$(printf \\x00    );b=${#a};#\\
" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))#\
=begin
#p             +555/2+55x%6E2x
;set print "-";print 89;exit#ss 9
utpb now 70 dollar off!
utpb has been selling out worldwide!
#9999 9 seeeemPaeueewuuweeeeeeeeeeCis:ajjappppppp95➡


set ! 57
set ! 51
More 91 of thiset of re9
How much is it*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449, 12597
#endif//*
#1"" //*
#include<stdio.h> 
#defineâ x(d)â#d
#define u8 "38\0 "
main ( ) {puts( sizeof (0,u8)-5?u8"67":*u8""?"37":     x( 0'0  "'\"")[9]?"75":'??-'&1? "79":"77");"eg5""6 27""e ' Zing  ";}//*/
#if 0
#endif//* --... ...--
/*/
p=sizeof("9( 999 99\"    ); print'(''72'')';end!"            );main( ){puts(  "92");return(9-9+9 -9);}
#if 0â
#endif//* rk:start | print: "69" rk:end<(9    >5b*:,1-,@
print 61
#}
disp 49 ;9;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>> /
reg end="";print(85);reg s#++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-.
=end
;"""#"#xxxxxxxy"78"\++++>/<~#class P{        function:Main(a:String[] )~Nil{83->Print();} }
#}pS9^7^8^MUOUOF@:8:8\\
#s|)o51~nJ;#:p'34'3  \=#print(17)#>27.say#]# print(47) #]#echo 21#fwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8âdggi2âM`|$//''  1$6~-<~-<~-<<<~-COprint ("65")#asss^_^_#
#9 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .002953 (to improve, next entry should be no more than 3042 bytes)

Rundown

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl, 86 in Miniflak, 87 in Alice, 88 in PingPong, 89 in gnuplot, 90 in RunR, 91 in Cood, 92 in C89, 93 in Set, 94 in Emotinomicon, 95 in Emoji, 96 in EmojiCoder, 97 in Cubically, 98 in Archway2, 99 in 99. 100 in brainbool

Verification

Try it online! Languages not available on TIO:

  • Japt, 7 online.
  • Reng, 19 online.
  • Deadfish~, 48 local.
  • Moorhens, 60 local. use moorhens.py from the v2.0-dev branch
  • Morse, 73 local
  • Archway, 74 local
  • Trefunge-98, 76 local. Use -d 3 -v 98 for Trefunge-98.
  • Objeck, 83 local
  • zkl, 85 local
  • PingPong, 88 local
  • RunR, 90 local
  • Cood, 91 online
  • Set, 93 online
  • Emotinomicon, 94 online
  • EmojiCoder, 96 online
  • Archway2, 98 local I can not test Archway2 because I don't have the proper C compiler, however stasoid has confirmed it works in archway2

Explanation

I can't believe we've made it to 100 languages. I would just like to take the time to thank everyone thats been involved in this process. Its been a fun ride and I hope to add a 100 more with you guys.

Brainbool has been in my eye for a while. However since brainbool can only output two numbers, 1 and 0 I have not been able to add it until now (I wasn't around for 10 and 11).

Brainbool is just like brainfuck, except instead of wrapping at 256 it wraps at 2. Brainbool also does not have a - because it is redundant with the +. Our brainbool code to output 100 is fairly simple:

+.+..

In order to mask the outputs for brainfuck we add a loop and a minus:

+-[.+..]

Now all thats needed is to find a place for the code to go. My place of choice was the first + at the top level of the brainfuck code on line 8. To substitute in the plus we added our code and a +-+ which acts as a + in brainfuck and a noop in brainbool.

+-[.+..]+-+

Cubix

I put my code before the Cubix capsule causing a mirror to move into the path of the pointer. In order to fix this I moved the capsule a couple of steps forward in front of the offending mirror and all was well.

Surprisingly nothing else broke not even the notoious incident.

Wheat Wizard

Posted 2016-12-06T18:59:02.963

Reputation: 33 549

Actually, brainbool can output aribtrary text. If you pass it the -b argument, it will build 1s and 0s into bytes and then outputs as characters. – Pavel – 2017-07-30T22:18:06.160

@Phoenix Well, that would have been nice to know before I waited for 2 months to post this. :P No worries though, its in the polyglot now so all is good. – Wheat Wizard – 2017-07-30T22:20:08.687

(Feature was implemented two days ago) https://chat.stackexchange.com/transcript/44255?m=39076825#39076825

– Pavel – 2017-07-30T22:21:44.993

1@WheatWizard I confirm that it works in Archway2. – stasoid – 2017-07-31T01:06:27.110

1Congrats! I notice the VIP score just dropped under 0.003 as well. – Ørjan Johansen – 2017-07-31T01:26:01.017

1I have to confess, back when you originally posted about adding this for 100/101, I didn't actually think we'd ever get here. This is pretty dang cool. – SnoringFrog – 2017-07-31T14:47:08.670

1@stasoid I'm working on getting Archway on TIO, just FYI. – MD XF – 2017-07-31T17:11:56.327

20

4. ><> (29 bytes)

#>>>>>>>>v;n4
print(1)#>3N.i2

This program prints 1 in Python 3, 2 in Vim, 3 in Minkolang v0.15 and 4 in ><>

Try it Online!

Code ran

#             - change direction to left
            4 - add 4 to stack
           n  - print as a number
          ;   - end the program

Yet another 2D language.

Has no effect on Minkolang as it adds characters after the direction changes, gets ignored by Vim for some reason. # is a comment in Python so no change their either.

Blue

Posted 2016-12-06T18:59:02.963

Reputation: 22 461

20

31. Modular SNUSP, 326 bytes

Program

#v`16/"<"6/b.q@"(: ::T):  ␉␉␉␉ :(22)S#;n4"14"
#>3N6@15o|>␉^*ttt*~++~~~%
#=~nJ<R"12"; ␉
#[␉
#`<`|
print((eval("1\x2f2")and (9)or(13))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{}[()])}\{})(\{}\{})'#46(8+9+9+9+9+=!)=#print(17)#]#echo 21#|/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
#8␛dggi2␛␉` |1|6$//''25  #>say␉␉ 27#T222999+/+23!@"26

As usual, is a literal ESC character and is a literal tab.

Rundown

This program prints 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

Why no links in the rundown? Because I've been working on something to make testing much easier, a test driver that runs the program in most of the languages listed here and prints the result. This should hopefully make adding future languages to the polyglot much easier. You can get the results of this program for 28 of the 31 languages via running the following TIO link (which is a test driver written in a mix of Bash, Perl, and A Pear Tree):

Try them online!

The link also produces the /-formatted code block seen above, and formats the code into a hexagon for you:

          # v 1 6 / " < " 6 / b
         . q @ " ( : : : T ) : :
        ( 2 2 ) S # ; n 4 " 1 4 "
       # > 3 N 6 @ 1 5 o | > ^ * t
      t t * ~ + + ~ ~ ~ % # = ~ n J
     < R " 1 2 " ; # [ # < | p r i n
    t ( ( e v a l ( " 1 \ x 2 f 2 " )
   a n d ( 9 ) o r ( 1 3 ) ) - ( 0 a n
  d 4 ) ^ ( 1 ) < < ( 6 5 ) > > 6 2 ) o
 r ' ( \ { ( \ { } ) ( \ { } [ ( ) ] ) }
\ { } ) ( \ { } \ { } ) ' # 4 6 ( 8 + 9 +
 9 + 9 + 9 + = ! ) = # p r i n t ( 1 7 )
  # ] # e c h o 2 1 # | / = 1 / 2 4 = x
   = 9 [ < $ + @ + - @ @ @ @ = > + < @
    @ @ = > + < ? # > + . - - . ] / #
     8 . d g g i 2 . | 1 | 6 $ / / '
      ' 2 5 # > s a y 2 7 # T 2 2 2
       9 9 9 + / + 2 3 ! @ " 2 6 .
        . . . . . . . . . . . . .
         . . . . . . . . . . . .
          . . . . . . . . . . .

Three languages are missing: V is too slow, and Reng and Modular SNUSP are not installed on TIO. Luckily, all three have online interpreters:

  • You can test the program in V/Vim (intended output: 2) here on TIO.
  • There's an online Reng interpreter (intended output: 19) here.
  • There's an online Modular SNUSP interpreter (intended output: 31) here. (It's advertised as just a SNUSP interpreter, but Modular SNUSP is the dialect it actually implements, as seen by the @ signs all over the page.)

All three produce the intended output, so all 31 programs are properly tested. (One thing that concerns me slightly is as to whether the Whitespace program is terminating correctly; however, the whitespace here is identical to the previous submission, so they're both right or both wrong. If it turns out that the program is indeed terminating incorrectly, both programs are likely to be fixable in the same way.)

Explanation

First off, the Hexagony, which always seems to need changing. It's actually much simpler than before; I moved the Hexagony code to just after the Trigger code, meaning that it's very near the end of the program, and the Hexagony "capsule" that prints 23 and exits gets to run almost immediately. The last line generally looks like a good place to put the capsule, as it means fewer commands that might potentially disrupt the Hexagony will run.

All the other changes are to do with the addition of the Modular SNUSP code. The first thing to note is that SNUSP starts executing at the first $ character in the program, and is a 2D langauge that exits after going off the edge of the program, and thus by placing the SNUSP program at the end of the long line (inside the Thutu code, at a point where Thutu will accept almost anything), we can ensure that SNUSP doesn't see any code from other languages, and most other languages won't care about the SNUSP. One language that did care was Perl 6, which is parsing angle brackets; I placed a < immediately before the SNUSP code to keep it happy (as the brackets were naturally almost matched anyway). The other language that cares is SMBF; . outputs in both SMBF and SNUSP, and we don't want to create extra output. Luckily, as seen by SMBF, this program is <.>>[…] followed by the SNUSP code, i.e. the current tape element is 0. So enclosing the SNUSP code in square brackets "comments it out" from SMBF's point of view.

As for the code itself, it uses a well-known trick for writing constants in Modular SNUSP in which you write a lot of "start procedure" commands in a row and effectively create a sort of base-Fibonacci number. The basic idea is that + encodes the number 1; @ adds together the number represented by the code after it, and the number represented by the code after it minus its first character; and = is a no-op (thus @= will double the number to its right). In this system, I picked @@@@=+@@@=+# as a representation of the number 48.

There's a problem here, though; the standard method of writing constants in SNUSP leaves the control flow behind the start of the program, and with a oneliner (which I wanted to write here for obvious reasons), there's no way to change the IP to point in any direction but right. This means we're somehow going to have to get the IP to pass the entire constant definition and continue to the right, without the program exiting (which # would normally do). In order to resolve this, I carefully used a definition of the number for which + was always preceded by =. This means that I can write code to set the second cell to 48 via @@@@=>+<@@@=>+<#, safe in the knowledge that none of the > commands will be skipped by an @ command (and thus we keep control of the tape pointer). Additionally, we know that at the final #, the first tape cell will still have its initial value. Therefore, we can use the first tape cell as a marker to know whether to return from the procedure definition or whether to continue to the right (we're inside a ton of procedures when doing that, but we exit the program by falling off the edge so that it doesn't matter).

The final SNUSP code, therefore, is $+@+-@@@@=>+<@@@=>+<?#>+.--.. The $ marks the start of the program. +@+- sets the first tape element to 1 (++-, but once the procedure started with @ returns, it'll start running the code from the - onwards, thus setting the tape element back to 0. ?# ends the procedure only if the first tape element is nonzero; thus we eventually end up after the # with the second tape element set to 50 (48 from the constant definition, plus 2 from the two >+< encountered when going to the right afterwards). Then all we need to do is >+.--. to output ASCII codes 51 (3) and 49 (1), and fall off the edge of the program (] is a no-op in SNUSP, and / reflects control flow vertically so that it runs off the program's top edge); this bit works identically to brainfuck.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

19

2. Vim (11 bytes)

print(1)#i2

This program prints 1 in Python 3, and 2 in Vim.

Just to get the ball rolling and to throw my favorite language into the mix early on. :)

It's a very straightforward answer.

print(1)#

just so happens to be a NOP in vim. (lucky for me) Then i2 enters insert mode and inserts a '2'. You can try vim online here

Of course, in python

print(1)

prints '1', and

#i2

is a comment.

DJMcMayhem

Posted 2016-12-06T18:59:02.963

Reputation: 37 405

2Is this V or Vim? The interpreter you linked to is technically "V". – mbomb007 – 2016-12-06T19:22:45.773

@mbomb007 Well, V is almost entirely backwards compatible, so the intention was vim. I suppose it technically is V though. Is it too late to change? – DJMcMayhem – 2016-12-06T19:53:14.157

2Not really, just edit the title in the answers. – mbomb007 – 2016-12-06T20:12:04.493

Does V have a way to exit Insert Mode? – mbomb007 – 2016-12-06T20:12:51.103

1@mbomb007 A literal ESC character will do it (which is why I had to use one in my submission). – None – 2016-12-07T00:05:16.427

I meant is there a printable character that can do it? Otherwise, is there another way to output in Vim that won't require an ESC afterwards? – mbomb007 – 2016-12-07T05:14:46.210

Vim restricts the use of all non-ascii characters... Ah well, no Aheui I guess... :'( – JungHwan Min – 2016-12-07T06:09:01.183

1Note for those testing this out: You need to make sure you don't have a cliipboard carried over from the previous Vim session. – Riking – 2016-12-09T07:14:28.870

I don't have Vim installed but I have Vi in which the i in print triggers insert mode - according to the man pages r is replace a character in both languages, why does Vim ignore that first i but not Vi? Thanks! – user3467349 – 2017-05-30T01:34:28.357

@JungHwanMin turns out that wasn't the case https://codegolf.stackexchange.com/a/142382/69655

– Potato44 – 2017-09-11T12:27:57.970

19

30. Whitespace, 296 bytes

#v`16/"<"6/b.q@"(: ::T):  ␉␉␉␉ :(22)S#;n4"14"
#>3N6@15o|>␉^*ttt*~++~~~%
#=~nJ<R"12"; ␉
#[␉
#`<`|
print((eval("1\x2f2")and (9)or(13))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{\/+23!@}[()])}\{})(\{}\{})'#46(8+9+9+9+9+=!)=#print(17)#]#echo 21#|/=1/24=x=90/
#8␛dggi2␛␉` |1|6$//''25  #>say␉␉ 27#T222999"26

␛ represents literal escapes.

␉ represents literal tabs.

This program prints 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 (tested here), 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.

Whitespace is another esolang with a limited character set. This one only reads tabs, spaces, and line feeds.

So once we take out all the stuff that Whitespace doesn’t read we’re left with the following code:

[space][space][space][LF]
[space][LF]
[LF]
[LF]
[LF]
[space][space][space][space][space][LF]
[space][space][space][space]

And the code to output 30 is this:

[space][space][space][tab][tab][tab][tab][space][LF]
[tab][LF]
[space][tab]

So the top 3 lines of the existing code were given extra spaces at the end of lines to meet the requirements. Note that line 1’s tabs and trailing space are in the middle of the line to accommodate ><>’s needs.

Line 2’s space was changed to a tab here. This seems to function Identically to a space for the 2D languages, but visually it doesn’t line up anymore. ¯\_(ツ)_/¯

After the instructions to output 30, the game became getting the rest of the necessary spaces and line feeds to do pointless things and compile correctly.

White space happens to have instructions that mark/goto a code location with a label that allows for an arbitrary number of tabs and spaces, so that helped couch the long line’s spaces. It also starts and ends with a line feed, so that helped us up some of the line feeds in lines 3-6.

The final line couldn’t have a linefeed without breaking Retina, so its instructions are to do some arbitrary math and stack manipulation.

Here’s the full code with spaces, tabs, and linefeeds replaced with our notation:

#v`16/"<"6/b.q@"(:[Space]::T):[Space][Space][Tab][Tab][Tab][Tab][Space]:(22)S#;n4"14"[LF]
#>3N6@15o|>[Tab]^*ttt*~++~~~%[LF]
#=~nJ<R"12";[Space][Tab][LF]
#[[Tab][LF]
#`<`|[LF]
print((eval("1\x2f2")and[Space](9)or(13))-(0and[Space]4)^(1)<<(65)>>62)or'(\{(\{})(\{\/+23!@}[()])}\{})(\{}\{})'#46(8+9+9+9+9+=!)=#print(17)#]#echo[Space]21#|/=1/24=x=90/[LF]
#8␛dggi2␛[Tab]`[Space]|1|6$//''25[Space][Space]#>say[Tab][Tab][Space]27#T222999"26[LF]

And here is a commented version of just the Whitespace:

Push 30 onto the stack
[space][space][space][tab][tab][tab][tab][space][LF]

Output the number at the top of the stack
[tab][LF][space][tab] 

Jump to label null if the top of the stack is negative. (it's not)
[LF][Tab][LF]

Label this location as [Space]
[LF][Space][Space][Space][LF]

Add the top two items on the stack and replace them with the result. 
[Tab][Space][Space][Space]

Store the stack.
[Tab][Tab][Space]

Edits: Hexagony turns out to skip over tabs just like spaces, contrary to my previous assertion. @ais523 was kind enough to update @Kenney's Hexagonizer to account for literal escapes and tabs. I had to modify it to correct my prior assertion about tabs being read as no-ops and to replace literal escapes with . because the character is wider than other characters, making the hex slightly misaligned. Here the link.

And this is our corrected current Hex:

          # v 1 6 / " < " 6 /
         b . q @ " ( : : : T )
        : : ( 2 2 ) S # ; n 4 "
       1 4 " # > 3 N 6 @ 1 5 o |
      > ^ * t t t * ~ + + ~ ~ ~ %
     # = ~ n J < R " 1 2 " ; # [ #
    < | p r i n t ( ( e v a l ( " 1
   \ x 2 f 2 " ) a n d ( 9 ) o r ( 1
  3 ) ) - ( 0 a n d 4 ) ^ ( 1 ) < < (
 6 5 ) > > 6 2 ) o r ' ( \ { ( \ { } )
  ( \ { \ / + 2 3 ! @ } [ ( ) ] ) } \
   { } ) ( \ { } \ { } ) ' # 4 6 ( 8
    + 9 + 9 + 9 + 9 + = ! ) = # p r
     i n t ( 1 7 ) # ] # e c h o 2
      1 # | / = 1 / 2 4 = x = 9 0
       / # 8 . d g g i 2 . | 1 |
        6 $ / / ' ' 2 5 # > s a
         y 2 7 # T 2 2 2 9 9 9
          " 2 6 . . . . . . .

Finally, I golfed out some needless characters, mostly added previously to line up Prelude parenthesis and Hexagony hexagons.

Nim’s code is back to echo 21 from echo 5+5+11

Hexagony’s #@46 is now #46

Hexagony’s code is back to /+23!@= from /+23!@

Prelude’s parenthetical alignment of (9) or (13) became (9)and(13)

Well, that’s all I got. Good Luck everyone!

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Verified working in Trigger. However, the start of the last line is confusing me; are those literal ESCs there, or spaces? You might want to use a Unicode ␛ to help disambiguate. (The TIO links also seem to be broken, meaning that they can't be used to disambiguate either.) Also note that SE replaces tabs with spaces, meaning that it's hard to get at the source code of your program unambiguously; it'd help to have a hexdump or some similarly unambiguous form. – None – 2017-01-06T01:19:58.700

failed to verify the whitespace – Rohan Jhunjhunwala – 2017-01-06T01:34:58.563

^the tio link for some reason lacks the code. – Rohan Jhunjhunwala – 2017-01-06T01:35:32.110

Here, I modified the Hexagonizer to handle literal tabs and ESC characters. (Credits: this was originally written by @Kenney and modified by me.)

– None – 2017-01-06T01:35:55.020

1I think I fixed all the links and added ␛ in places of the space that resulted from my copy pastes. Not sure how to get tabs to be tabs in SE, the code in Tio should disambiguate. I also had to re-create my solution from the instructions in this answer, but somehow ended up with 2 fewer bits... Oops? – Chance – 2017-01-06T02:35:34.797

You can do Trigger in TIO now. – Pavel – 2017-01-06T02:55:24.417

1Just noticed a mistake in your explanation: carriage return (ASCII 13) is a different character from line feed (ASCII 10). The vast majority of languages (including Whitespace) care about the 10s, not the 13s (and it's assumed that a line break in a PPCG submission is just a single ASCII 10 unless otherwise stated, because the 13s tend to inflate your byte count to no benefit). – None – 2017-01-06T03:43:39.060

@ais523 thanks for the explanation. I've always assumed line feeds and carriage returns were synonyms. TIL. Updated explanation and added trigger link. – Chance – 2017-01-06T03:51:28.817

1

Your hexagony explanation image is wrong (prints e23) because of ; after the e when coming up NW after first reflection. The above link works tho...?

– Mistah Figgins – 2017-01-06T06:34:57.283

1I have come to the conclusion that the TIO for Hexagony treats tab characters as spaces/newlines. The image you provide of the hexagony program does nothing but exit if you follow it (or put it into TIO, replacing tabs with .s). However, copy the code in the image into TIO, except remove the training .s (not part of the actual code) and all the ␉s. It prints 23. – Mistah Figgins – 2017-01-06T06:58:36.827

The image ends up hitting a # with 118169 as its ME, activating IP 3, which hits another # with ME 9, (so it continues unaffected) up NE to the @. This is the path it takes. Also, from the specs: "Hexagony first strips all whitespace characters." - pretty sure this means tabs too

– Mistah Figgins – 2017-01-06T07:14:53.513

1Wow, thanks @MistahFiggins! It looks like I made some deductive errors and propagated them to my explanation. I've corrected the Hexagony explanation, hex diagram, and Hexagonoizer Perl script, as well as cross checked the result against Hexagony directly. Everything should be good now. Good Find! – Chance – 2017-01-06T16:45:16.917

Which language needs the bunch of /\{})([]s in line 6? – Mistah Figgins – 2017-01-06T18:45:23.133

@MistahFiggins The string ({({})({}[()])}{})({}{}) are a couple of math operations in Brain-Flak. All the \ s are because Japt doesn't like the {} in what I believe it perceives as a string, so the \ s escape out the {. I wrote a bit about this string in answer 28, and how it can interact with Hexagony if that helps you. :) – Chance – 2017-01-06T20:53:59.063

18

35. INTERCAL (C-INTERCAL), 631 bytes

#v`16/"<"6/b.q@"(: ::Q):  ␉␉␉␉ :(22)S#;n4"14"
#>3N6@15o|>␉^*ttt*~++~~~%
#= >␉1#v#v0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#[␉
#`<`|
print((eval(" 1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))or' (\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"␉*
""""#//
=begin␉//
$'main'//
#-3o4o#␉
=end   #//
"""#"#//
#0]#echo 21#/ (\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE) a
#   +/Jn~
#8␛dggi2␛`␉|1|6$//''25  >>>#>27.say# =#print(17)#$nd^_^_.]Q222999/+23!@1#"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 them online!

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required. I tested Incident locally on my own system, using the official interpreter.

Note that I added a few changes to the test driver in order to make it easier to spot hidden characters; various NUL bytes had crept into the program's output in certain languages. I've decided that this probably isn't a problem, because a) a wide range of submissions have been doing it, and b) the Befunge interpreters seem to be adding extra NUL bytes even though nothing in the program implies that (unless I've missed something), so it must have been going on for ages and is probably part of how the interpreter works. (Note that the languages that still output NUL bytes – the Befunges and Minkolang – haven't had their code changed for this submission.)

The previous Rail submission exits via crash, which is disallowed, but this is easily fixable (by adding a # at the end of the Rail program and adjusting the Hexagony to match) and so I didn't consider it a major problem. The Rail in this solution exits correctly.

Explanation

How the INTERCAL code works

INTERCAL parses the entire program. However, syntax errors are a runtime thing in INTERCAL, not compile-time, and this is often used to create comments. (If a syntax error attempts to execute, it'll crash the program with error ICL000I, contrary to what Wikipedia incorrectly claims. But if you can prevent it executing somehow – and INTERCAL has a lot of ways to prevent commands running – it'll quite happily not execute without causing a problem.)

As such, we can prevent garbage at the end of the file running simply by exiting the program explicitly first (something that's required anyway, because INTERCAL crashes if the end of the program is reached without an explicit exit command). Handling the start of the program is more interesting, and exploits a parser bug. You can write something like DO %20 READ OUT #8 to output VIII with a 20% probability (and otherwise do nothing). As far as I can tell, C-INTERCAL parses the lone % on the second line as indicating a 0% probability for the first command to run, and thus ends up consistently not running it every time. (I'm not sure why it parses it like that, but looking at the compiled code shows it generating a random number and comparing it to 0.)

Here's how the INTERCAL program looked before fitting it around the rest of the polyglot:

DO,1<-#2
DO,1SUB#1<-#52
DO,1SUB#2<-#32
DOREADOUT,1
PLEASEGIVEUP

This is fairly simple: instantiate a 2-element array; set the elements to 52 and 32 (decimal) respectively (INTERCAL's string encoding is best left unmentioned; I've forgotten how it works and had to do various experiments to figure out why these numbers encode 35); read it out to standard output; and exit the program. I added an additional PLEASE at the end in order to terminate the GIVE UP statement, starting a new statement for the garbage at the end of the program, whilst keeping in acceptable bounds for polite conversation. Of course, the INTERCAL doesn't look quite like that in the finished product; I'll explain why as we go.

Buried under a load of Ses

The most obvious issue with the INTERCAL program is that it contains the letter S. This is pretty much unavoidable, as there's no way to index an array without using the letter in question. However, S is an output command in Underload, and there's no way to prevent it parsing the entire program. The only solution is to place the INTERCAL code inside parentheses, Underload's equivalent of a string literal, so that it doesn't run immediately.

However, we have two ^ characters at the end of the program, which execute Underload code; so those Ses are going to get executed anyway if we don't do something about it. I could have changed it to another character, but decided it was easier to protect the code so that it becomes meaningless. a escapes a string in Underload (meaning that ^, upon executing the string, will simply unescape it again rather than producing harmful side effects). We already have one a in the say used in the Perl 6 code (which in this arrangement of the code, is actually enough due to unrelated changes). However, so that people don't have to rely on that, I added another a at the end of the line (I wanted a character there anyway to make what would otherwise be trailing spaces visible, and because Hexagony needed padding as it is; note that the Hexagony was fairly easy to fix in this program, and doesn't really need separate discussion). So the Underload code is a little less fragile than it could have been.

Prelude to a lot of work and confusion

Ah, Prelude. Not normally the most difficult language, but it definitely was this time. There are two real problems: one is that adding extra parentheses on a farly long line runs the risk of disturbing the control flow of the Prelude program (as they create the equivalent of a while loop), and one is simply the problem of preventing them lining up vertically (which is responsible for most of the random moving around of whitespace on lines). Note that the Whitespace gave me some trouble too, but this program is equivalent to the previous one from Whitespace's point of view, so it was pretty much a case of "fix the Prelude without breaking the Whitespace".

I'm not too sure how the Prelude actually works at this point. There are several fixes intended for it, like the 0 near the bottom-left corner, but they clearly don't function in the way I intended them to. (The Julia code also ended up moving to the bottom of the line because the parentheses in its print statement were really hard to deal with.) Perhaps we'll just have to leave it a mystery.

Breakdown in a Fission reactor

Although the changes above were for fairly subtle problems which are hard to fix, there's a much more obvious problem; DOREADOUT matches the regex R...O, and thus will cause Fission to produce unwanted output on the fourth cycle, which is not enough time to output the intended output of 12. And INTERCAL only has one instruction that produces output (unless you count crashing as output). One fix to this is to try to add whitespace between READ and OUT, to give us time to intercept the output, but that makes Whitespace angry. So for a while, I thought this program was impossible; R, L, U, and D are all entry points in Fission, and all capable of potentially running problematic code, and INTERCAL keywords must be in uppercase.

However, there is a fix, and a fairly surprising one. As part of an internationalization effort, C-INTERCAL actually accepts keywords in multiple languages, with support for both English and Latin. We couldn't avoid S like this, but we can avoid O; FAC is a perfectly good substitute for DO, and likewise LEGERE EX means the same thing as READ OUT. (The program thus ended up in a mix of English and Latin, but that's OK; it hardly makes it any less readable.) As such, we can happily let Fission go mad in the bottom right corner, and just not let it produce any output. We can change the actual Fission code to end with * rather than ;, which quits the entire program rather than just one thread; this code runs fairly quickly, so it exits the program before all the stray entry points have time to do any damage.

Knit 6, Perl 6

The next problem: The Perl 6 comments work by matching < and >. INTERCAL's assignment operator is <-. Luckily, that adds extra opening brackets, so I could just add a few closing brackets to cancel them out in an unparsed location in the program (just after the Pip code, in this case).

However, I didn't want to change the whitespace budget of the program, but moving the Julia code (for Prelude) ended up adding an extra space to the last line; I had to remove one from somewhere. The double space is a comment marker in Pip, so I could hardly change those; the only remaining option is the space in say 27. Perl 5 golfers would immediately think "well just do say+27 then" (unary + comes in handy surprisingly often!), but unfortunately this isn't valid Perl 6 syntax.

What we can do, though, is to change say from function syntax to method syntax. Integer literals have a bunch of methods, including one to print them out, so 27.say is a perfectly valid program of the same length.

Be square? Don't be there

So the next issue is that I've added an extra . to the program. SMBF users will know that that's clearly a problem in that language, producing stray output (NUL bytes in this case). There was already a . producing stray output last program, but that doesn't mean I shouldn't take the opportunity to fix it.

The basic idea here is to create an SMBF loop to comment out the offending instructions. This means moving the square brackets around. I took them from around the SNUSP code (because they were only there for the sake of Incident anyway, and Incident doesn't care where in the program they are), and placed the opening bracket at the start of the INTERCAL code, and the closing bracket just before the Trigger (thus neatly hiding both .s).

Unfortunately, square brackets are meaningful to Retina; it sees […<-#… and says "that makes no sense, you can't create that range because < doesn't come before #". Fortunately, this is easily fixable with a strategically placed backslash.

The centre-of-the-program incident

This happened last answer, and it's probably going to happen repeatedly from now on; various strings happened to randomly occur three times, and shifted around the centre of the program from Incident's point of view.

The most urgent token to handle was 1#, which appears three times if you make these changes naively: #= >␉1# at the start of the third line, __DATA__=1#, and echo 21#. Why is this a problem? Because the 1# on the third line overlaps the #v just after it, and two overlapping tokens causes neither of them to be counted. And #v is the token we used to comment the code before the Incident program out! I fixed this by sneaking in an extra 1# very near the end of the program (only three characters follow it); none of the languages that parse that part of the program do anything with it.

There were various other problematic tokens to deal with. A couple were single letters, P and U; I dealt with these via changing a couple of filler no-ops in the Incident code from x to P or U respectively, giving a fourth copy. The change to the Fission code leaves * as a token, but notably, this is split differently from normal, appearing twice before the Incident code and only once afterwards. Instead of removing it, therefore, I used it to partially balance the new LE token that appeared in the INTERCAL code. That's enough to drive the centre of the program back over an 0o token. Of course, changes to the program are quite likely to disturb this. (My attempts to get Incident onto TIO failed due to libdivsufsort not being available there, so it looks like we might benefit from a new interpreter, especially in JavaScript so that it can run online. If you're interested, take a look at this question.)

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

1Wow, this challenge has come a surprisingly long way. Great job! – Mistah Figgins – 2017-01-26T17:57:00.500

Latin?! Wow, what a great solve! I love that the code says 'please give up' now. It's like it's daring me to quit. – Chance – 2017-01-27T06:54:30.123

17

11. Befunge 98, 102 bytes

#v;2^0;7||"<+0+0+0+<;n4
#v0#_q@
#>3N.
#|\w*
#8  ^1b0<
#|
#M`
print(None and 9or 1/2and 1or 5)
#jd5ki2

Prints:

To be perfectly honest, I have no clue why the Vim code takes 1 min to output. Also, no clue how Retina works.

Explanation:

#v          Skips the v, which would send the IP down
  ;         Unlike '93, where ; is a no-op, '98 skips to the next ;
            and doesn't execute anything in between
   2^0;     Not executed, unlike Befunge 93
       7|   Pushes 7 onto the stack, and then sends the IP up, because 7 is not 0
n0b1        n clears the stack, and #s are pushed until the stack is [0, 11, 1
    *.      multiplies the top 2 values of the stack to give 11, and prints it (yay!)
      _     Sends the IP right, because the top value of the stack is 0
       q    Ends the program (no-op for '93, which continues to @)

Things to note:

  • The 0 next to the b isn't strictly necessary in the code's current state, and the stack has been cleared. It can be removed if necessary, but allows for other stack manipulation beforehand as part of a possible future program.
  • The _q@ is there as part of Retina (It doesn't work without it, don't ask me why). The addition of q also lets the '98 code run a t operation, which splits the IP (along with making the Retina program print 8 instead of 7)
  • The _ is not a simple > because that would mess the SMBF part up.

Edit: Just realized that the _q@ should probably be @00 (Where 0s can be ~any char) to make the program more flexible in the future. I'm too lazy (and tired) to change all the links right now though. Will get around to it eventually...

Edit 2: I Didn't expect 6 more answers this quickly. I guess it's staying as is. Great job everyone!

Mistah Figgins

Posted 2016-12-06T18:59:02.963

Reputation: 2 362

Heh, I wrote my 11th answer, only to realise that it had already been posted, now I changed it to the 12th answer :) – Cows quack – 2016-12-07T08:26:38.893

Wow! Awesome!!! – JungHwan Min – 2016-12-07T13:46:14.220

Any Idea why Vim takes so long to execute? – Mistah Figgins – 2016-12-07T16:15:38.000

@MistahFiggins I guess it is because the code has to be converted to keystrokes, but other than that, I have no clue – Cows quack – 2016-12-07T16:16:16.350

I wrote that vim interpreter, and I have no idea why it takes so long. I haven't noticed many performance issues before, but that's because most of my V/Vim answers are less than 40 bytes. Not really sure what's causing it, but lots of people have been complaining about that on this thread. – DJMcMayhem – 2016-12-07T23:00:03.950

17

51. Assembly (x64, Linux, AS), 1086 bytes

#16  "(}23!@)(" 3//*v\D@;'[af2.qc]'#)"14";n4
#/*` PkPPZ (22)S"[!(>7 7*,;68*,@;'1,@␉␉␉␉ q
#>␉
# >36!@␉
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++EAL+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52PLEASE,2SUB#2<-#32DOREADOUT,2DOGIVEUPDOiiipsddsdoh]>+.-- -. >][
#x%+>+=+~tt .
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v01k1kx0l0ix0jor0h0h1d111x0eU0bx0b0o1d0b0e0e0@O6O4/0m1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l111111^_)  0046(8+9+9+9+9+=!)
###|
'\';echo 50;exit;';print((eval("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))or"'x"or'({({1})({1}[(0)])}{1}\{1})'#}#(prin 45)(bye)|/=1/24=x<$+@+-@@@@=>+<@@@=>+<?#d>+.--./
__DATA__=1#"'x"//
#.\."12"__*'
###;console.log 39
""""#//
=begin //
#sseemeePaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#
#"`#"\'*/{puts (p);}/*'"`"
/*
<>{#65}//
#}
disp 49#//
#{
1}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo  21
#sss8␛dggi2␛ `|1|6$//''25  16*///89^_^_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.

Want to learn more? Try the polygot chat!

Try it online!

VIP score (Versatile Integer Printer): .008186 (to improve, next entry should be no more than 1151 bytes)

This program prints 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 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.

  • 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.

  • For Deadfish~, can be tested to output 48 with this. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are an unavoidable consequence of running any Deadfish~ program.

  • Assembly can be tested to output 51 here

Thanks and Congratulations

When @ais523’s 50-in-1-k answer dropped 2 weeks ago, a tear rolled down my cheek. It was too beautiful. And it was in Bash. It was too perfect.

I turned to my wife and said “I think the polyglot is done,” feeling immense pride.

She turned to look me in the eye, paused a moment, and said “Good. Now take out the trash.”

What she meant though was that she felt deep joy for me and my internet friends. Thanks and congratulations to everyone.

Assembly Explanation

In the days that followed, my mind kept wandering back to something @ais523 said in polyglot chat shortly before posting Bash. He pointed out that some flavors of assembly use # based line comments and /* block comments. Well that was enough for me to slowly lose my mind for the next 2 weeks.

There is a kind of implicit challenge in polyglots to include legitimate languages. I’m using the term legitimate here very loosely, but I think we can all grok what I’m getting at. It’s a one thing to include Brainf***, but it’s another thing entirely to include the likes of Mathlab or R. Assembly certainly falls into the latter category, and my mind couldn’t let it go. But I knew nothing of Assembly, so this was an uphill battle.

After banging my head against the problem for a while, looking for a way for Assembly and C/C++ to coexist, I found this is the documentation for the GNU assembler:

To be compatible with past assemblers, lines that begin with '#' have a special interpretation. Following the '#' should be an absolute expression (see Expressions): the logical line number of the next line. Then a string (see Strings) is allowed: if present it is a new logical file name. The rest of the line, if any, should be whitespace.

This I noticed happened to be quite similar to our pre-processor directive for C/C++ in line 1 of the polyglot. After some trial and error I found that #1 “bla” 1//* would enter a block comment for Assembly only.

And so a polyglot was made.

With the biggest blocking problems solved, I set out to golf down this hello world example.

.intel_syntax noprefix
.section .data
     msg: .asciz "51"
.section .text
.global _start
_start:
    # write syscall
    mov     rax, 1
    # file descriptor, standard output
    mov     rdi, 1
    # message address
    mov     rsi, OFFSET FLAT:msg
    # length of message
    mov     rdx, 14
    # call write syscall
    syscall
    #End the Program
    mov    rax, 60
    mov    rdi, 0
    syscall

Primary Author’s Credit

Actually I lied a minute ago, the very first version of the Assembly code I used was in AT&T syntax, which is one of two syntactic branches of Assembly. One of the main elements of AT&T syntax is that it’s register references use a % prefix and this is a problem for the polyglot. Cardinal uses % as a pointer origin, so if we littered a bunch of % about, it’d be like a second Fission reaction.

The other syntactic branch, which doesn’t use % as a register prefix, is called Intel syntax. The exploit we’re using in the polyglot to get past the first line and enter a block comment is in the GNU Assembler (GAS or AS for short). AS has the happy feature of allowing both syntactic branches. You just have to declare that you want to use Intel syntax, which is happening on Line 1 of the Assembly code.

Assembly uses registers, which are a small number of memory locations literally located on the CPU for speed of access. This isn’t unique to Assembly other than the fact that their use is not abstracted away from the developer’s concern.

There are different kinds of registers which are used for different purposes. From Wikipedia:

• AX multiply/divide, string load & store

• CX count for string operations & shifts

• DX port address for IN and OUT

• BX index register for MOVE

• SP points to top of stack

• BP points to base of stack frame

• SI points to a source in stream operations

• DI points to a destination in stream operations

AX is used in line of the _start Function here: mov rax, 1. The r in rax indicates that the memory is 64-bit. If we swapped this for an e, that would indicate a 32-bit memory, which is totally valid to do with a 64-bit processor. We just wouldn’t use the top half of the available memory. To indicate 16-bit memory, you just use ax, which is fine for us because we’re just printing integers. So we can golf a few bytes by changing all the register references to 16-bit.

Okay, not quite all the register references could drop the r. mov rsi, OFFSET FLAT:msg. If you’re familiar with Assembly, but not this statement, it’s because this was semi unique to AS. At least, that what I gleaned from this, which helped me gold down the statement to just lea rsi,m.

After this, I experientially found that I could knock _start: down to just _p and cut .global _start entirely with only a warning issued. Second, msg: was reduced to just a single character variable p:. I chose p for both the string variable and the starting function to offset some of the s Assembly added for Alphuck’s benefit.

Then, I put in ; to delimit instructions in order to put them all on one line. This is primarily to avoid excessive trailing #//s on each line for Thutu’s benefit. Also, I noticed that our Assembler didn’t appear case sensitive, so I just upper or lower cased various characters to avoid Incident imbalance.

This golf'd us down to:

.intel_syntax noprefix;.text;mov ax,1;mov di,1;lea rsi,m;mov dx,2;syscall;mov ax,60;mov di,0;syscall;m:.asciz "51"

After all this, Japt and Underload were the only problem children in this answer. Japt had some beef with the * added in line 1, but it seemed to be fixed by reverting to the puts(p); line from the C++ answer. I ended up throwing a ( in this line as well and then closing it on Octive’s line. This was so Underload would stop sefaulting. A similar treatment was had on line 1 to add in the * there.

This was enough to meet the byte requirements of this challenge. In fact I verified this by producing this version of the polyglot. But I wanted to attempt to improve the VIP score as well if possible. And since I had a fulfilled all the requirements of the challenge, I felt ok about collaborating to golf down the code. So I stopped over at polyglot chat to seek some golfing help.

We must go deeper

@ais523 demonstrated a technique of passing the instructions to the assembler as machine code with this statement.

.text;.long 2298589328,898451655,12,178790,1018168591,84934449,12597 Machine code is a series of numeric instructions executed directly by the CPU which can be represented in decimal, Hexadecimal or Octal. For our purposes decimal is the shortest since (hex takes a leading 0x to represent). The .long statement here is making the declaration that what follows is a series of decimal machine code instructions.

Well I poked at this statement as well for a bit to see what the assembler would allow, and made a couple changes. First, I found that I can remove .text; all together, with only warnings issues, which was a pretty sold byte saving. Then a while later I also found, this statement in the AS spec documentation

.long is the same as .int

Cool. So, we can make that swap for a quick byte. Now our assembly, but really machine code, was cut down to this:

.int 2298589328,898451655,12,178790,1018168591,84934449,12597.

While this is all well and good, it’s quite difficult to work with machine code directly and I wanted to at least see how to make all the translations. So ideally, we’d want to dissemble the machine code back to assembly. The easiest way of doing that is to take an object dump, which @ais523 demonstrated for me with this code snippet.

Here’s the code snippet.

And here’s just the Assembly.

nop
mov    $0x1,%al
mov    %eax,%edi
lea    0xc(%rip),%rsi
mov    $0x2,%dx
syscall 
mov    $0x3c,%al
xor    %edi,%edi
syscall 
.byte 0x35
xor    %eax,(%rax)

That link also shows some 2 character hex numbers alongside each line of assembly. Those correspond to the decimal instructions. For example, if you put 2298589328 into this decimal to hex converter, you get 8901B090 back. And if you look closely, those are the first 4 hex instructions from the object dump (in reverse order).

From what I can tell, sets of 4 hexadecimal numbers are always used to convert to decimal and the main byte saving trick being use here is to structure the assembly so that the last several hex numbers in our 4 sets are 00. These will then transform to leading zeros when we put them into the .int statement which are just omitted.

This is what’s happening in the 12 statement. In hex portion of the object dump this is 0c 00 00 00.

This is as far as my understanding of Assembly has gotten in 2 weeks. What a crash course!

Incident

Incident was a more difficult solve in the shorter assembly implementation because it weighted the polyglot tokens much heavier to the top. Here is the Incident report.

  • ! in line 2 detokenizes !

  • The first EA on the INTERCAL line detokenizes itself

  • The last space on the second to last line detokenizes a space-space token.

  • 85 on the last line detokenizes

  • The R in #<R>"3"O. detokenizes R

  • 65 in <>{#65 }// tokenizes 65

  • 16 on the last line detokenizes itself

  • 89 on the last line tokenizes itself

Cardinal

I just realized I made a change to Cardinal that I forgot to document. I spent some time poking around looking for ways to save bytes, and decided to learn Cardinal. After a little time with the documentation, I saw this line.

= copies the pointer's active value into its inactive value.

This was not a trick being used in the polyglot. The old solution included these instrucitons: `++~*t

++ incriments up to 2.

~ changes the active stack

* adds the stacks.

I realized that ~* could be achieved with just the = instruction, so I reworked the solution to take out some useless stack swapping and add in this small byte saving.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

3I'm intrigued as to how you can even keep polyglotting to this amazing stage. How??? – Qwerp-Derp – 2017-04-05T07:19:09.870

3This is truly a thing of pure beauty. – Muzer – 2017-04-05T15:37:38.023

Unary should be next – Christopher – 2017-04-06T16:00:44.150

No, that would murder the VIP score (unless the code was 3 bytes or less) – CalculatorFeline – 2017-04-26T16:24:53.387

16

6. SMBF, 45 bytes

#v<++++<;n4
#>3N.
print('1'if 1/2else'5')
#i2

Try it online

This program prints 1 in Python 3, 2 in V, 3 in Minkolang v0.15, 4 in ><>, 5 in Python 2, and 6 in SMBF.

SMBF (aka Self-modifying Brainfuck) uses <++++<>.. The pointer is moved left (to the last character of the source code), and the cell is incremented four times then printed.

mbomb007

Posted 2016-12-06T18:59:02.963

Reputation: 16 876

16

10. Befunge, 95 bytes

#v02^0;7||"<+0+0+0+<;n4
#v0#@00
#>3N.
#|\w*
#8
#|
#M`
print(None and 9or 1/2and 1or 5)
#jd5ki2

There is a literal ESC character between j and d on the last line (grr, @ais523). It is not included in this code. To get the actual code, please go to the Try it online link.

This prints 1 in Python 3, 2 in Vim, 3 in Minkolang, 4 in <><, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, and 10 in Befunge.

This code shares * with Retina and . with Minkolang and SMBF.

Try it online

Explanation

Actual program

#v02^
    @
    .
    *



    t
    5
#v02^

The last line was written for clarity (Befunge playground is cyclic.)

#

Trampoline, skips v

02^

Push 0 and then 2 in stack and go up.

5t*.@

Push 5, no-op, multiply two elements in stack (2 and 5), print, end program.

JungHwan Min

Posted 2016-12-06T18:59:02.963

Reputation: 10 551

1This makes SMBF print a null byte at the first .. – Pietu1998 – 2016-12-07T00:31:34.993

@Pietu1998 fixed! – JungHwan Min – 2016-12-07T01:31:16.447

Hey, it wasn't me who chose to use a language where many of the most important commands are nonprintable characters… (In other news, I was considering Befunge as a strong possibility for adding to this polyglot; it seems to fit in well with the other languages. I like the way you did it, although it may well need modifying to fit in more.) – None – 2016-12-07T02:26:19.247

@ais523 I agree that modifying this code may be difficult. To alleviate this, I put in some 0s to indicate that those characters can be anything (except the "&lt;+0+0+0+&lt;;n4 part) and parts of the Befunge code may be moved around. And a tip for the next person: most of characters are no-op in Befunge, so adding more lines is not likely going to affect the Befunge code. – JungHwan Min – 2016-12-07T02:36:20.290

Thinking about making a befunge-98 (or other similar funge) submission, because they add a fair amount of operations that are no-ops in regular '93. It might be hard to fit though, and I would need to figure out how all the other languages worked so I could work around them... – Mistah Figgins – 2016-12-07T05:30:15.267

Is it Befunge-95? That'd be pretty cool; Befunge-95 with a byte count of 95... – MD XF – 2017-06-08T03:56:56.123

16

13. Ruby (129 bytes)

#v;2^0;7||"<+0+0+0+<*!2'!1'L;n4
#v0#_q@
#>3N.
#|\w*
#8  ^1b0<
#|
#M`
print ((0 and'13')or(None and 9 or 1/2 and 1 or 5))
#jd5ki2

Please note the literal Esc character on the last line between the j and d, as per ais523's Perl answer.

Try it online!

This prints 1 in Python 3, 2 in Vim, 3 in Minkolang, 4 in <><, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge, 11 in Befunge-98, 12 in Fission and 13 in Ruby.

Just a minor modification to the existing print statement to abuse the fact that 0 is truthy in Ruby. I had to add some spaces to the other statements to make it parse correctly.

Dom Hastings

Posted 2016-12-06T18:59:02.963

Reputation: 12 968

16

15. Haystack (141 bytes)

#v;2^0;7||"<+0+0+0+<*!2'!1'L#'1r'4;n4
#v0#_q@
#>3N.15o|1
#|\w*
#8  ^1b0<
#|
#M`
print ((0 and'13')or(None and 9 or 1/2 and 1 or 5))
#jd5ki2

Note: there is an ESC after o in the third line and after j in the last line

This prints 1 in Python 3, 2 in Vim, 3 in Minkolang, 4 in <><, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in turtlèd, and 15 in Haystack.

Try it online!

Explanation

#v                           go down
 v
 >                           go right
  3N.                        does nothing important
     15o|                    outputs 15 and ends program
                             there is an <ESC> after 'o' since 'o' in Vim enters insert mode
         1                   I added this to satisfy Retina

Cows quack

Posted 2016-12-06T18:59:02.963

Reputation: 12 883

Awesome, thanks for checking out Haystack! :) – Kade – 2016-12-07T13:51:35.170

@Kade It's a nice 2D language, an online interpreter would be more helpful (although I have already downloaded the Python interpreter) :) – Cows quack – 2016-12-07T14:13:27.613

@Kade There is a TIO link for haystack now! – Cows quack – 2016-12-08T05:47:39.160

@MistahFiggins The link works for me and outputs 15 – Cows quack – 2016-12-08T05:58:14.753

@MistahFiggins Cache? Because it works for me without any problems or any error messages – Cows quack – 2016-12-08T06:00:15.473

How do you go about getting a language to be supported by TIO? – Mistah Figgins – 2016-12-08T06:10:04.100

@MistahFiggins I asked Dennis in the tryitonline chatroom – Cows quack – 2016-12-08T06:11:03.810

16

21. Nim (161 bytes)

#v`16/"<"6/b.q@#;n4"14""
#>3N6@15o|> ^*ttt*~++ %
#=~nJ<R"12";
#[

print((1/2and 9 or 13)-(0and+4)^1<<65>>62)#46(89999+++++!)=#print(17)#]#echo 21
#8dggi2` |1|6

Two <ESC>s, between 8d and between 2` on the last line. You can tell that my previous one was golfed in a hurry, because I woke up this morning and realised I could take a bunch more off. I had 152 bytes but that seems to only work in Perl 5.24.0, so in the interest of compatibility with TIO I've kept the original expression for now.

Prints 1 in Python 3, 2 in V, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtléd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude and 21 in Nim.

Note that Nim on ideone.com uses version 0.11.2, which is a tad too old, since this program relies on #[ ... ]# multiline comments added in early 2016.

Thanks to Cardinal's Windows interpreter, my workflow now consists of two laptops and a Python http.server in between.


Edit — some more hints:

  • The 8 at the start of the last line is to set Retina's limit to the first 8 matches, otherwise without it Retina would output 2. Note that this means the final line regex only needs to match at least 8 times in the second last line now, as opposed to exactly 8 — during my meddling I modified Prelude to get Retina right, but it turned out that was unnecessary in the end.
  • The mismatched quote at the end of the first line is so that Pyth doesn't complain about invalid syntax for the rest of the code.
  • If you modify the second line you might have to change the 6@ for Minkolang, which makes the pointer jump 6 spaces to land on the ^.
  • There's a pair of [] now, so SMBF needs to be on a 0 cell before it hits the [, or alternative the interior needs to clear the cell.

There's probably more to golf (even now I see a stray space before the % for Cardinal), but I should really stop golfing in the wee hours of the morning.

Sp3000

Posted 2016-12-06T18:59:02.963

Reputation: 54 224

1TIO now supports Cardinal – Mistah Figgins – 2016-12-08T19:17:22.557

16

27. Perl 6, 235 bytes

#v`16/"<"6/b.q@"(::):::  (22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++~~~%
#=~nJ<R"12";
#[
#`<`|
print((eval("1\x2f2")and 9 or 13)-(0and 4)^1<<65>>62)#@46(8+9+9+9+9+=!)=#print(17)#3]#echo 21#===2|/=1/24=x=90/
#8␛dggi2␛` |1|6$//''25  #>say 27#"26

␛ represents a literal ESC character, as usual.

This program prints 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 (tested here), 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 Vim/V, 1 in Python 3, and (as it's Christmas) a partridge in A Pear Tree.

The syntax highlighting that Stack Exchange produces for this answer is completely wrong. #`< is one of Perl 6's many multiline comment markers, and ends at #>, thus the only code that actually runs in Perl 6 is the very simple say 27. I chose this particular comment marker because <> aren't a matching pair in most languages, and thus the unmatched < won't break languages, such as Retina, that attempt to parse it.

I'm not entirely sure how the Hexagony works any more. When it broke, I changed one of the characters it was using from a + to a 0 to see if it was being hit; turns out it was, and turns out this fixed the program, but I'm not sure why (I know it broke due to a # in the line of execution, but it's unclear why removing the + fixes things). (The character in question is also parsed by Thutu, but luckily this doesn't make a difference to the functioning of the Thutu program, as at that point in the program, anything that isn't preceded by an = is copied literally into the working string.) Note that the 0and+4 from a previous line became 0and 4, to make it one character shorter from Hexagony's point of view (Hexagony doesn't see spaces); this is to compensate for the #| on a previous line becoming #`<`|, which is one character longer from Hexagony's point of view (because it doesn't see backquotes either). Note that the code's now only five bytes away from expanding the Hexagony side length and breaking everything about the current Hexagony code. I'd recommend doing this anyway and just redoing the Hexagony section of the code; it'll probably be easier, rather than harder, to fit everything in after an expansion.

Some other languages changed too, mostly to add enough robustness that I could fit arbitrary code in on the last line. $// is a comment marker in Japt that allows spaces later on the line, making the added program less fragile in Japt (meanwhile, // breaks if there are any closing parentheses later on the line, and space is a sort of closing parenthesis in Japt). A pair of spaces is a comment marker in Pip, meaning that the Pip code can be substantially simplified here. This also means that we can simplify the 05AB1E down to a trivial "26. Retina needs the fifth line to be a legal regex that's good at matching things (the trailing | is thus for Retina); it parses differently from the corresponding line in the previous entry, but in a way that's just as suitable. The Cardinal is also very slightly simpler than in previous entries, but this is just pure coincidence with how everything lines up vertically, and the change is to code that didn't do anything anyway.

Assuming you redo the Hexagony (you'll probably have to), there are safe places to add code on all of the last three lines: the 3 in #3]# is only for Hexagony (and easily changed); the space between the # and " on the final line is ignored by the vast majority of languages; and nothing's really parsing the end of the fifth line other than Retina. (There are plenty of other places where code can be added, too, but these are probably the most convenient.)

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

I accidentally downvoted this answer and noticed I downvoted when i noticed my rep's gone down by 1. Can you edit the answer so I can upvote? :D – betseg – 2016-12-25T09:37:42.513

3@betseg: I added a bit more discussion of the Hexagony, just for you. – None – 2016-12-25T12:37:14.697

Congrats on the bounty! I wanted to get this post moving again :P – FlipTack – 2016-12-25T15:26:16.290

I'd been planning to continue it for ages, it was just a case of trying to find the time. (I'd actually made a failed attempt at Perl 6 a while back, earlier in the chain, and didn't post it because it didn't work. Luckily, I learned from the mistakes and it works this time.) – None – 2016-12-25T21:19:27.213

16

41. brainf***, 916 bytes

#  4"16" 3//v\(@#/;\D"14"<;n4
#/*`3 afaaZ">;[77*,68*,@;'1,'1,q)(22)S#   ␉␉␉␉ (
#yy␉;36!@
#`<` ␉
#=␉x
#<]+<[.>-]>[
#␉<
###xR+++++[D>+++++++L+++<-][<<<]>+.---.>][
#px%>~~~+␉+~*ttt*.x
#D>xU/-<+++L)
#R+.----.R␉>]|
#[#yy#yy0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#|␉
print((eval("1\x2f2")and(9)or(13   ) )-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"␉*
###; console.log  39
""""#//
=begin␉//
#*/
#define␉z  sizeof 'c'-1?"38":"37"
#include<stdio.h>
int main()  /*/
#()`#`\'*/{puts(z);}/*'``
$'main'␉//
#-3o4o#$$$
<>"3"O.<␉>//
#
=end   #//
"""#"#//
#0]#echo 21#/(\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE)  a>>>
#>27.say# /7Jn~15o|  
#8␛dggi2␛`␉|1|6$//''25  =#print(17) ###^_^_LEintnd"3"z!]/}23!@/*///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 (Versatile Integer Printer): 0.01329

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required.

The Test Driver has been updated to include the Tokenizer, finally. All the C code is stored as an argument from the Bash Script’s perspective. I also changed the output to wrap horizontally with a trailing space after each token instead of outputting vertically. This was just my preference, to make it match the Whitespace output. But anyone else can change it if they feel like it’s too confusing.

I also made a Test Driver adjustment to handle column spacing for Turtlèd’s UFT8 char in the rundown. That misalignment was driving me nuts! The “fix” is pretty hack-ish since it just looks for an è and changes the column width for that case, but it gets the job done.

Explanation

First off, I want to say how awesome @SnoringFrog’s Versatile Integer Printer Score Rundown code snippet from the last post was. I’ve been calculating answers before posting for a while, and this has re-inspired me keep it small. I think we can beat @sp3000’s answer eventually.

So I started working on this answer by trying to golf down what I could and I was pretty successful. I even had an answer in a different language with a total byte count smaller than #40. But as I tried to golf down Minimal-2D, I had to learn BF so I could better work with its derivatives and in the process I found @Primo’s record breaking Hello, World!. I fell in love the elegance.

Minimal-2D, it turned out, was not efficient enough to utilize the tape initializing technique used by @Primo, but I’m of the opinion now that it would probably be too byte heavy anyways. We are only trying to print an integer after all. But @Primo did send me down the path to learning how to multiply in BF, which I brought to the Minimal-2D’s code.

Then after all this, I re-read @SnoringFrog’s comment about how to include BF and realized that not only could I do it, but I could use much of the Minimal-2D code I had golfed down in the BF answer. So I dug in to answer with BF, and here we are.

One more thing before I get into the details. There were a couple changes I made for non-golf reasons. First, I moved the bulk of the code @SnoringFrog added to just below the 2D languages in the top several rows. To me, it is a long term strategic move to prevent 2D-langs from traversing the center of the polyglot in order to prevent future bugs where possible. The byte hit was low for this move, so I went for it.

Second, during the various re-factors I learned that the Begunges and Minkolang output a trailing space after numeric outputs and that this was the cause of the null bytes we’ve been seeing in the Test Driver for these languages. I fixed these by outputting the stack’s value as an ascii code (which did not include the trailing space feature), instead of the value directly. There was a small byte hit for this change as well, but now the Test Driver’s output is so uniform. How could I not?

SM/BF

Let’s quickly go over the basics. These are the only valid commands for SMBF and BF:

>   Move the pointer to the right
<   Move the pointer to the left
+   Increment the memory cell under the pointer
-   Decrement the memory cell under the pointer
.   Output the character signified by the cell at the pointer
,   Input a character and store it in the cell at the pointer
[   Jump past the matching ] if the cell under the pointer is 0
]   Jump back to the matching [ if the cell under the pointer is nonzero

Both languages have a memory tape where values are stored and changed. SMBF’s only difference is that whatever code is being executed is also stored on the memory tape to the left of the starting point. As @SnoringFrog pointed out, getting SMBF and BF to produce different results hinges on moving the memory pointer to the left of the origin. In Tio’s BF interpreter, the memory pointer is capable of moving left of the origin and will find 0’s instead of the Polyglot’s ascii codes that SMBF sees. Here’s an example that can be run in both SMBF and BF to exemplify the difference.

At the start of the polyglot, the Befunges require the > on the second row to run to completion and Perl6 requires that every > be preceded by a <. So SM/BF start with <> to leave the memory pointer at the origin, then hit a [ which jumps some offensive characters for both languages to the ] on the 6th row.

Next, we increment the origin memory cell for both languages and move the memory pointer to the left with +<. (For conversational convention, we’ll call the origin memory cell as cell 0, cells to the right of the origin 1, 2, ... And cells to the left -1,-2, …). Cell -1 contains the asci code of the last character in the polyglot in SMBF and 0 in BF, so when the next [ is encountered, only BF jumps to the next ] while SMBF passes into the code.

As SMBF traverses [.>-] it prints the 6 found at the end of the polyglot and then moves the memory pointer back to cell 0, setting its value back to zero to exit the ]. To review, the tapes at this pint are: SMBF’s negative cells hold the polyglot, and it’s 0 and positive cells hold zero. BF’s negative and positive cells hold zero while it’s origin cell holds 1.

Next the > moves SMBF to cell 1 and BF back to cell 0 allowing BF to enter it’s private code block: [<+++++[>++++++++++<-][<<<]>+.---.>] (I’ve removed the non-BF characters from this). Here, we move back to cell -1 and initialize our loop control variable (cell -1) to a value of 5. Then we enter the loop where we add 10 to cell 0 and decrement cell -1 five times before exiting the loop where we will be pointing at cell -1 with a value of 0.

Next we encounter [<<<] while pointing at a zero, so BF doesn’t pass through this. The purpose here is to balance a number of >’s with preceding <’s so Perl6 doesn’t error out.

At this point cell 0 is valued at 51. The ascii value of 4 is 52, so we move the pointer to cell 0 add 1, then print the value. And finally, we decrement cell 0 back to the ascii character 1 and print again before setting the memory pointer to cell 1 (value 0) to exit past the ].

SMBF and BF both hit the last [ on line 8 next while both are resting on a 0 value. So both jump past the remaining Minimal-2D code until the ] is encountered on line 11. But this is short lived because line 12 starts with another [ which takes both languages to almost the end of the polyglot where no further instructions are encountered.

Refactors

Minimal-2D

Minimal-2D’s re-write was mostly to save some bytes in a fashion similar to BF’s multiplication trick. Minimal-2D however doesn’t have the [ and ] characters for loop control. Instead it has these commands:

/   Skips next instruction if the data pointer is set to 0.
U   Tells the program to switch to the up direction of processing instructions.
D   Tells the program to switch to the down direction of processing instructions.
L   Tells the program to switch to the left direction of processing instructions.
R   Tells the program to switch to the right direction of processing instructions.

These can be used to produce the same logic structure, albeit in a 2D manor, as that of BF. For example, BF’s ++++++[>++++++<-]>. is equivalent to this in Minimal-2D.

Here is a simplified version of Minimal-2D’s code in the polyglot, with all the extraneous code removed and all the place holding characters replaced with #.

###################D
###R+++++[D>+++++++L
###>
D>#U/-<+++L)
R+.----.R

The D in line 1 sends the instruction pointer down to the L in line 8 of the polyglot which sends the pointer to the left. Here we set the loop control variable (cell 0) to 7, move the memory pointer to cell 1 and enter a loop. In loop, we add 3 to cell 1, decrement cell 0 then check if cell 0’s value is zero yet. If not, we add another 8 to cell 1 then decrement and check again. The result of this loop is cell 1’s value is set to 51 at the end of the loop (6*8+3).

We exit the loop by hopping the U, moving the memory pointer to cell 1 and going down then to the right on line 11 of the polyglot. And finally, we increment up to the ascii value for 4 then decrement down to the ascii value for 0 before running off to the right to end the program.

Retina

Retina had a lot of requirements that were difficult to work with for all the BF derivatives. It doesn’t like consecutive +’s or mismatched () or []. But these are really just requirements for every other line, so a lot of the work for BF, SMBF and Minimal-2D revolved around putting the bulk of the code on even numbered lines.

The one byte committed solely to Retina though is the | at the end of line 11. To quote @ais523 “most regexes ending with | will match anything”. Without this, Retina returns 0. Why this fixes it, I don’t know. I haven’t had to dig into Retina too much, probably because I’ve been avoiding the long line. But like Prelude, I’ve found I don’t need to understand it as much as I need to understand how to debug it, which in this case mostly consisted of deleting lines (in multiples of 2) until I’ve found the line that’s causing it to break. I guessed at this fix based on @ais523’s comment, and was rewarded. I’m just too cool for school I guess.

Cardinal

I happened to like @SnoringFrog’s placement of Minimal-2D relative to Cardinal’s code. It’s a good location considering Cardinal doesn’t upset Retina, and it seemed to allow some interweaving with Minimal-2D. So when I set out to transplant Minimal-2D up to 2D land, I brought Cardinal along for the ride. There were a couple cosmetic changes to Cardinal though. First, I threw a > near the beginning of its statement #p x%>~~~+ +~*ttt*.x for Minimal-2D to change memory pointers within its loop/ Second, I shifted everything one character to the right to give Minimal-2D room to exit it’s loop gracefully. The p in this sting is for this character padding.

Befunge/98

The Befunges are actually where I started out trying to golf down the polyglot, since the C++ refactor changed all the other 2D lang code, except this one. In trying to learn WTF was going on in this code, I found this in the Begunge documentation:

The . command will pop a value off the stack and output it as a decimal integer, followed by a space, somewhat like Forth. , will pop a value, interpret it as the ASCII value of a character, and output that character (not followed by a space.)

Holy moley! We can clean up the null bytes on the output. After this, it was all just a matter of figuring out how to input the larger asci values, and segregating the code. Befunge-98 had a jump code ; telling it to skip over the [77*,68*,@ in ;[77*,68*,@;'1,'1,q, which gave us the segregation.

Befunge-98 also had a command (') to take the ascii code of the next character. So, '1, takes the code asci code for the character 1, puts it on the stack and then prints the ascii character for the top value on the stack with ,. Just gotta do this twice to print 11 and drop a q to quit out gracefully.

Befunge proper is a little less convenient, but only just. Here we have to perform a calculation to put the desired code on the stack. Fortunately, our codes were easily multiplied with 7*7 and 6*8 before the same output command,. Then we quit out of Befunge with @ before its older brother’s code contaminated the output.

Minkolang

After finding a fix for the Befunge’s trailing spaces I got pretty hyped up on the idea of finding a Minkolang fix too and Minkolang’s documentation said that output command that had been used up until this point worked in the same way as the Befunge Interpreter. O happened to be documented as another output command, that wasn’t described as sharing this Begunge-ness, so I just took a shot in the dark and tried outputting the string "3". Flawless Victory.

><>

One of the first things I looked at when moving the Minimal-2D code was verifying that I could move ><> along with it. If I was going to deal with 2D polyglot transversalism, I was going to deal with all transgressions. I basically luck sacked my way into the solution of putting ;n4 at the end of line 1 and moving the \D further back in line 1. BTW, I didn’t know that ><> could be directed down before answer 40 since it’s been so well contained. I’d like to think this could be used later to diverge ><> from another similar language.

Perl6

I’ve talked about some of Perl6’s <> balancing issues elsewhere in this answer, so I’m not going to go over it again. But I do want to point out that I moved #>27.say# to the second to last line. This doesn’t have a functional purpose in this answer. I actually made this move to satisfy a different answer that I ended up not using this round. I decided to just leave it since I plan to post that answer at my next opportunity and I didn’t want to bother undoing and re-doing it.

Bug Fixes

05as1e

05as1e definitely didn’t like the new Begunge code as much as the old version. I’d suppose it’s the ,s since that’s the only revolutionary character. In any event, I had to move the " further back in line two to hide the offensive commands, and I knew that the " had to go prior to the Befunge code path since " was a yes-op in both languages. (I can just make up terms like yes-op right?) Line 2’s 2-dimentionality is pretty rigid, but I was able to displace the < prior to Begunge’s code path with the ". The < however was a requirement of Perl6. (It has to have a < preceding all >s.) I was able to drop the < in line one at a location divined by instinct and foreknowledge resolving 05ab1e and Perl6’s disagreement.

Whirl

The Befunge changes on line 2 added an extra 1 to the polyglot prior to the Incident/Whirl line. This extra 1 caused Whirl to start off pointing to the wrong instructions on the wheel. The very first 1 in the C/C++’s preprocessor directive was only a line number reference in the code, and this could just as easily be any other line number, so I arbitrarily changed this to 4 to satisfy Whirl.

Incident

The detokenizing string at the end of the polyglot is well known at this point, so I won’t go into it. I removed from the string what I could and added the new tokens that were required. There are 2 detokenizing characters that are not in this string though that I should point out. First, the second R in #R+.----.R >]| is needed here because it’s a Fusion starting point, and it was safer on this line because there was already a Fusion starting point heading in the same direction. Second, the x in #= x is to remove a token involved in a ␉␊# pattern, which has become more common.

Others

Hexagony, Whitespace, and Prelude all had the usual minor adjustments, but nothing special worth talking about.

Final Thoughts

That’s all I’ve got for this answer. For those looking for a starting point on the next answer, I’d suggest evil. It seems workable, although I haven’t looked at it too closely, but I suspect it would not be too hard to integrate. I know it has a jump command that should help skip past the bulk of the polyglot. Good luck.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Fails in Incident (it prints 3333 then waits for input), but is likely easily fixable. The problem is that you've placed a token (-]) after the ^- token that was previously used to jump to the end of the program. The other two uses of -] are consecutive, so that forms a …xx…x… pattern, which is a backwards jump. Moving that last -] a little earlier (or the ^_s a little later, or both), though, is likely to be fairly easy. – None – 2017-02-16T00:51:23.297

@ais523 Thanks. This is what I get for golfing while writing. Always remember to check the Incident kids. Fortunately I was able to fix this one with addition by subtraction, so overall win I think. – Chance – 2017-02-16T08:01:50.123

1If you run the V with -v (for verbose) you can replace a literal escape charater with &lt;esc&gt;, which might make working with the code in the future a bit easier. (I think) – Pavel – 2017-02-19T22:22:13.707

Wow! Thanks @ais523 for the bounty. What a great way to start Monday morning! – Chance – 2017-02-21T21:52:33.827

Befunge-98 is older than Befunge-93? – CalculatorFeline – 2017-05-01T21:29:22.593

@CalculatorFeline Looks like they were made in 93 and 98. http://catseye.tc/node/Befunge-93.html http://catseye.tc/node/Funge-98

– Chance – 2017-05-02T02:30:57.387

So Befunge-98 is older than Befiunge-93? – CalculatorFeline – 2017-05-02T03:06:33.693

@CalculatorFeline my belief is 93 is older. – Chance – 2017-05-02T06:04:53.760

15

36. Labyrinth, 647 bytes

#v`16/"<"6/b.q@"(: ::Q):  ␉␉␉␉ :(22)S#;n4"14"
#>3N36!@@15o|>␉^?.*ttt*~++~~~%
#= >␉1#v#v0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#[␉
#`<`|
print((eval(" 1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))or' (\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"␉*
""""#//
=begin␉//
$'main'//
#-3o4o#␉
=end   #//
"""#"#//
#0]#echo 21#/ (\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE) a
#   +/Jn~
#0␛dggi2␛`␉|1|6$//''25  >>>#>27.say# =#print(17)#$nd^_^_.]Q2229991#;abcd!fghij/+23!@"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 them online!

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively. @ais523 helped debug and fix the Incident code, which now works.

How Labyrinth works

Labyrinth starts off shifting some of the columns in the source around a little, but after a few steps the pointer gets to where the N is on the 2nd line (initially, by the time the pointer gets there it's no longer an N there), moving right, with a 0 at the top of the stack. Then, it simply pushes and prints a 36 and terminates with 36!@

Things I Done Broke

I knew I wanted to add Labyrinth, as it's one of the few esolangs I know a bit about. With it's debugger, I found that by changing the 8 in the last line to a 0, Labyrinth didn't get stuck in an infinite loop and, oddly, nothing else seemed to break. From there I just dumped in the raw 36 and output command I needed, and those conveniently led to an @ to terminate things.

Then, it was on to repairing what I broke: Minkolang, Cardinal, and Hexagony.

The ! was making Minko skip the next character, which it needed to terminate, so I just added an extra @. So far, so good.

The change in length of the 2nd line made Cardinal miss it's output statement. Trying to add an extra . on the first line made Prelude lose its mind (no clue why, honestly), so I went a different method and just dropped it in the second line. That inadvertently spawned a 3rd Cardinal pointer, so I padded things with a ? (not a necessary choice, just the first thing I found that fixed both Fission and Cardinal).

Hexagony was fortunately a relatively simple fix, I just threw in a string of letters so that the pointer found the code. I figured the alphabet shouldn't have appeared before and wouldn't cause problems with Incident. This is also when I realized I hadn't tested Incident. Thanks to @ai523, I found out I just needed an extra exclamation point, so the e in the alphabet string was changed to a !.

Scores from The versatile integer printer

Just for kicks and going of off @Stewie Griffin's comment on the question, here's a snippet that shows how each answer would have scored if it was entered into "The Verstatile Integer Printer".

// This was stolen/sloppily hacked together from the snippet here: https://codegolf.stackexchange.com/questions/55422/hello-world. Feel free to clean it up if you'd like.
/* Configuration */

var QUESTION_ID = 102370; // Obtain this from the url
// It will be like http://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "http://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=asc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "http://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)[,\(].*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function getScore(langs, bytes) {
  var l = Math.pow(langs,3);
  return bytes/l;
}

function process() {
  var valid = [];
 
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
        score: getScore(match[1].split(".")[0],+match[2]).toFixed(5),
      });
    else console.log(body);
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery('<a>'+lang+'</a>').text();
    
    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link, score: a.score};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    return a.lang_raw.split(".")[0] - b.lang_raw.split(".")[0];
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.score)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#language-list {
  padding: 10px;
  width: 400px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list">
  <h2>Scores from <a href="https://codegolf.stackexchange.com/questions/65641/the-versatile-integer-printer">The Versatile Integer Printer</a></h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

SnoringFrog

Posted 2016-12-06T18:59:02.963

Reputation: 1 529

1OK, it looks like this only slightly causes problems with Incident; the program's off-centre due to now having exactly three exclamation marks, but this can easily be fixed by changing a filler character to a fourth exclamation mark. I changed the e in the alphabet you added to an exclamation mark; that seems to work. – None – 2017-01-27T22:05:03.770

1Nice! I've been secretly waiting for labyrinth, so good on you. On a separate note, the best part of the code so far (for me) is the "PLEASEGIVEUPPLEASE" message, telling you to just stop trying. ;) – Mistah Figgins – 2017-01-30T05:45:58.477

15

67. C11, 1674 bytes

#16  "(}o+?23!@)-("//*\Dv;'[af2.q]PkPPX'#CO)"14";n4
#/*0|7//```"`   [-'v][!(>77*,;68*,@;'1,@10␉␉11)(22)S␉␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#_>++++.>.+?+++++::@
#`<`
#<]}} +<[<.>>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++59xL+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#
#x4O6O@
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_00)
[ "]56p26q[puts 59][exit]" ,'\[' ];#/s\\/;print"24";exit}}__DATA__/
#
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.
#
'((( p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A )echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>){(<{}(({}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#( prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{nd
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define u8 "38\0"
#define p sizeof'p'-1?u8"67":"37"
#include<stdio.h>
main ( ){puts( p);}/*
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.s
=end
"""#"
#}
#sx|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm 
# sss8␛dggi2␛`|$// ''25  16*///~-<~-<~-<<<~-XCOprint("65")#s^_^_2229996#

VIP score (Versatile Integer Printer): .005565 (to improve, next entry should be no more than 1749 bytes)

Try it online!

Numbers

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11

Verification

Most languages can be tested with the test driver above, but 6 languages have to be tested manually:

  • Reng (#19) online.

  • Modular SNUSP (#31) online.

  • Incident (#33) local.

  • Deadfish~ (#48) local. Run like this: deadfish.py < polyglot. Prints a bunch of >> lines, but that's an unavoidable consequence of running any Deadfish~ program, so it's okay.

  • Moorhens (#60) local. Note that moorhens.py from master branch doesn't work.

  • Surface (#66) local.

Explanation

Adding C11

I am using the trick with utf-8 literals (introduced in C11).

#define u8 "C99\0"
puts(u8"C11");

This trick can also be used to distinguish C++11 from C++03.

Cubix and Retina broke as a result.

Cubix

Cube size 16 -> 17. Moved 4O6O@ further in file, it ended up on line 13 (#x%+>+=ttt Z_*.), which broke fission, cardinal and minimal-2d. So I placed 4O6O@ on a separate line instead and padded it with #x.

Retina

I ended up adding 2 lines (#define u8 "38\0" and #x4O6O@), so total line count remained odd, which is good for retina. But retina still didn't work. So I moved empty line around to fix it (line 20 in answer 66). This empty line ended up before #x4O6O@. Thutu broke, so I added # to that line.

Surface

Surface still prints NULL character before 66, I didn't fix it. (It is fixed in the next answer.)

stasoid

Posted 2016-12-06T18:59:02.963

Reputation: 3 177

Given that #38’s C has so far been tested with bash run-wrapper.sh gcc -o polyglot polyglot.blah.c, I would prefer to define #38 as the C11 answer, and #67 as the C99 answer, but that is trivial. Nice Addition! – Chance – 2017-06-05T15:56:20.537

I thought surface printed a null character, but when I run it on my machine I don't seem to get it in my output. How are you running surface? – Wheat Wizard – 2017-06-05T16:28:15.743

@WheatWizard I run surface.exe on my Windows 7 32-bit machine. In console window I see blank space before 66 (NULL char is displayed exactly like a space char). If I redirect output to a file I can see it in hex viewer: ...0D 0D 0A 00 36 36 │ 0D 0D 0A 0D 0D... (newlines and other text are added by interpreter). Also, python program print("\x00\x01") produces exactly the same output (minus newlines and interpreter text) as surface program .+.@ - a blank space followed by a smiley face (char \1). – stasoid – 2017-06-05T19:15:54.543

@stasoid Hm, I'll investigate perhaps it is a difference between running on windows and using Wine. I may have also made a mistake. I did run it through a hex editor but I might have missed it. – Wheat Wizard – 2017-06-05T19:39:05.967

14

14. Turtlèd (135 bytes)

#v;2^0;7||"<+0+0+0+<*!2'!1'L#'1r'4;n4
#v0#_q@
#>3N.
#|\w*
#8  ^1b0<
#|
#M`
print ((0 and'13')or(None and 9 or 1/2 and 1 or 5))
#jd5ki2

This prints 1 in Python 3, 2 in Vim, 3 in Minkolang, 4 in <><, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge, 11 in Befunge-98, 12 in Fission, 13 in Ruby and 14 in Turtlèd.

First line added #'1r'4 near the end of line, Turtled takes #[string]# as string input then 'X places the value of x on the grid, r moves right 1 space on the grid. The value on the grid is printed at the end of the program implicitly.

Try it Online

Link to Turtled docs

Teal pelican

Posted 2016-12-06T18:59:02.963

Reputation: 1 208

@Sp3000 - edited and fixed (should be) – Teal pelican – 2016-12-07T09:34:59.847

@L3viathan - This link should work - it contains the missing ESC literal from the last line

– Teal pelican – 2016-12-07T09:48:01.870

hooray! My language is used. Also it has a capital t, unlike brainfuck – Destructible Lemon – 2016-12-08T05:26:23.507

@DestructibleWatermelon It's a fun little language for some challenges :) I saw you post a while back and thought I'd pick it up just in case. – Teal pelican – 2016-12-08T08:42:20.767

14

16. Pyth (159 bytes)

#v\;2^0\;7||"<+0+0+0+<*!2'!1'L#'1r'4;n4
#v0#_q@
#>3N.15o|1
#|\w*
#8  ^<1b0 <
#|
#M`
print ((0 and'13')or(None and 9 or 1/2 and 1 or 5))
#"07|5//00;16 "jd5ki2

Note: there is an ESC byte (0x1B) after the o in the third line and after the j in the last line.

This was quite a fun experience. Japt and Pyth are both golfy languages, but Japt is infix and Pyth is prefix, and Pyth auto-requests input and fails if arguments are missing.

Before the Haystack answer I had an almost-working solution using #, which gets a char code in Japt and loop-until-error in Pyth. Pyth happens to be very useful in polyglots, since the common comment char # essentially works as an error silencer.

When I got home I managed to find a this piece of code that worked in both using //, which works as a comment in Japt and two divisions in Pyth. Then it was just a matter of getting the Befunges to route correctly.

This is very unlikely to be optimal, but it's good enough for now. I tried to test them all, but I'd highly appreciate someone double checking that the outputs match.

Prints 1 in Python 3, 2 in V, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in Self-Modifying Brainfuck, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge(-93), 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtléd, 15 in Haystack, and

16 in Pyth.

Explanation

What Pyth sees here is:

#v\;2^0\;7||"string
multiline
string"07|5//00;16 "string

This translates to the following pseudocode:

while no errors occur:
    evaluate ";"
    print 2
    print 0 to the power ";"
    print 7
    print "string\nmultiline\nstring" or 0 or 7
    print 5 or 0 divided by 0 divided by (missing)
print 16
do nothing with "string"

The first loop exits on trying to evaluate ; which isn't a valid expression. Then Pyth just prints 16.

Pietu1998

Posted 2016-12-06T18:59:02.963

Reputation: 14 919

Extending in what way? I still need another 5 or so bytes available for my answer ;) – Alfie Goodacre – 2016-12-07T12:48:05.667

@AlfieGoodacre By adding the rest of the details to the post. I just wanted to remain sane and thus posted my code before anyone stole my place. :D – Pietu1998 – 2016-12-07T12:51:56.560

13

8. Retina, 70 bytes

#v;7||"<+0+0+0+<;n4
#>3N.
#|\w*
#8
#|

#M`
print('1'if 1/2else'5')
#i2

Try it online

This program prints 1 in Python 3, 2 in V, 3 in Minkolang v0.15, 4 in ><>, 5 in Python 2, 6 in SMBF, and 7 in Japt.

Screw creating hyperlinks to interpreters. That's going to take way too much time. It's up to the poster and anyone creating new answers to test it yourself.

Explanation:

#v;7||"<+0+0+0+<;n4     # replace every empty string with "#>3N."
#>3N.
#|\w*                   # replace words chars with "#8"
#8
#|                      # remove all "#". The "|" is something I could've golfed off.

#M`                     # match all places between characters (finds 8)
print('1'if 1/2else'5') # replace something that won't be found. noop
#i2

mbomb007

Posted 2016-12-06T18:59:02.963

Reputation: 16 876

This is 2 bytes too long (50 + 20 is 70, 50 + 20% is 60). – None – 2016-12-06T20:30:50.297

1@ais523 Fixed it. – mbomb007 – 2016-12-06T20:36:50.417

2Care to provide an explanation? If not, that's ok. – Mistah Figgins – 2016-12-07T05:41:56.623

@MistahFiggins Sure. Added. – mbomb007 – 2016-12-07T14:44:18.497

12

1. Python 3 (8 bytes)

print(1)

This program prints 1 in Python 3.

Starting this off with Python 3 because I know it's good for polyglots and can be taken in a number of different directions (also, I wanted to ensure that the first answer was in a relatively normal language, rather than an absurd esolang that's hard to polyglot with).

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

Would ><> be a good choice for the 2nd language (so that we start 2d space)? – Cows quack – 2016-12-06T19:07:32.407

So that means the next answer can't be more than 9 bytes? That's gonna be really hard to come up with another one. – DJMcMayhem – 2016-12-06T19:09:04.193

1@DJMcMayhem Each answer must be no more than 20% or 20 bytes (whichever is larger) longer – Cows quack – 2016-12-06T19:10:47.920

12

7. Japt (50 bytes)

#v;7||"<++++<;n4
#>3N.
print('1'if 1/2else'5')
#i2

Man, it was fun to fit Japt in there. Hopefully it didn't kill anyone's plans...

Test it online!

This program prints 1 in Python 3, 2 in V, 3 in Minkolang v0.15, 4 in ><>, 5 in Python 2, and 6 in SMBF.

How this works: #v; takes the char code of v, or 118. Then 7|| returns the logical OR of 7 and the rest of the code, which is wrapped in a string with " to avoid any syntax errors. The result, 7, is automatically sent to STDOUT.

For future polyglotters, " can be changed to ` at no penalty to the Japt program (though I'm not sure about the others).

ETHproductions

Posted 2016-12-06T18:59:02.963

Reputation: 42 391

12

9. Perl, 84 bytes

#v;7||"<+0+0+0+<;n4
#>3N.
#|\w*
#8
#|

#M`
print(None and 9or 1/2and 1or 5)
#j␛d5ki2

There's a literal ESC character in the actual code between the j and d; it has been replaced with a ␛ here for visibility.

This prints 1 in Python 3, 2 in Vim (tested locally, but here's a link for the very similar language V), 3 in Minkolang, 4 in <><, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, and 9 in Perl.

Let's get some more exoteric languages in, via abusing arithmetic that works differently in different languages. (None is falsey in Python but truthy in Perl, and and/or chains work the same way in both languages.)

Apart from Python, I also had to change the vim code. Instead of making it into a series of no-ops, I just let it insert junk, then deleted the junk again at the end.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

3Seriously? You're going to make it extremely difficult for anyone else to create answers if you put in a literal ESC. We have to be able to test the code. – mbomb007 – 2016-12-06T22:55:53.040

You don't have to include the literal ESC in your own answers; I just found it to be the easiest way to write this one. (Additionally, it works fine in Firefox, and in local testing; the only thing blocking me from putting it in the post is that Chromium, which I use for SE, doesn't want to put it into the input box.) – None – 2016-12-06T22:58:40.917

Also, you can't test locally for Vim. Languages are defined by the interpreter that is used. So it's really V that we've had all this time. – mbomb007 – 2016-12-06T22:59:04.657

1Err, isn't vim an interpreter for Vim? (It works in both vim and V, though.) – None – 2016-12-06T22:59:57.223

It has to be the same interpreter that the original answer used. – mbomb007 – 2016-12-07T05:12:23.057

4@ais523 maybe you can put ␛ to represent the 0x1B byte? – betseg – 2016-12-07T05:49:03.930

@ais523 how do I use esc literals? – Alfie Goodacre – 2016-12-07T13:40:54.877

@AlfieGoodacre An ESC character is just a character like any other; the main problem is that it's hard to type, as pressing ESC normally doesn't work. If you can get one from somewhere (such as my try-it-online links above, or by writing a program to output the character with code 27), you should be able to copy and paste it. However, if you're doing it in a browser, this only seems to work on Firefox; Chrome can't handle it. – None – 2016-12-07T14:03:15.103

@ais523 thanks, that answers it because I use chrome - I didn't end up needing it for my answer but I might for languages that come before it's actually valid – Alfie Goodacre – 2016-12-07T14:07:36.117

12

19. Reng, 152 bytes

#v`16 "<" 6/b0\ .q@#;n4"14""
#>3N9@15o|R"12"*^*ttt*~++%
#=|
print((1/2and 9 or 13)-(0and+4)^1<<65>>62);# =#;print(17)
#       ~nJ<
#
#gg99ddi2` |1|1+6

I added another #\n so that retina would cooperate. Here's how it works:

# redefines v to push 0, the default TOS. Then, it negates the TOS (`), pushes 1 and 6, the character of <, pushes 6 again, and mirrors upwards with /, colliding with the other `, which negates the 6. Then, it hits the <, pushes J (base 36 for 19), then outputs it as a number, finally terminating (~).

Escapes in between 2 and `; and # and g.

  1. Try it online!—Python 3
  2. Try it online!—V
  3. Try it online!—Minkolang
  4. Try it online!—><>
  5. Try it online!—Python 2
  6. Try it online!—SMBF
  7. Ethproductions—Japt
  8. Try it online!—Retina
  9. Try it online!—Perl
  10. Try it online!—Befunge 93
  11. Try it online!—Befunge 98
  12. Try it online!—Fission
  13. Try it online!—Ruby
  14. Try it online!—Turtléd
  15. Try it online!—Haystack
  16. Try it online!—Pyth
  17. Try it online!—Julia
  18. Try it online!—Cardinal
  19. JSFiddle—Reng

Conor O'Brien

Posted 2016-12-06T18:59:02.963

Reputation: 25 859

12

24. Thutu, 211 bytes

Fourth try. Hopefully the implementation is uncontroversially valid this time.

#v`16/"<"6/b.q@"(::):::  (22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++~~~%
#=~nJ<R"12";
#[
#|
print((eval("1\x2f2")and 9 or 13)-(0and+4)^1<<65>>62)#@46(8+9+9+9+9+=!)=#print(17)#3]#echo 21#===2|/=1/24=x=9+/
#8␛dggi2␛` |1|6

␛ represents a literal ESC character, as usual.

As far as I know, there isn't a Thutu implementation that works in a browser yet. I used the implementation in the Esoteric Files Archive, which is a compiler from Thutu to Perl (basically, compile the Thutu into Perl, then run the Perl). Update: Since I wrote that, the language has been added to TIO. So now you can:

Try it online!

This program prints 24 in Thutu, 23 in Hexagony, 22 in Underload, 21 in Nim, 20 in Prelude, 19 in Reng (test here), 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, 8 in Retina, 7 in Japt, 6 in SMBF, 5 in Python 2, 4 in ><>, 3 in Minkolang, 2 in Vim/V, and 1 in Python 3.

I had to pretty much redo the Hexagony part of the solution. It turns out to be easiest to run the Hexagony code on a diagonal, rather than horizontally:

        # v 1 6 / " < " 6
       / b . q @ " ( : : )
      : : : ( 2 2 ) S # ; n
     4 " 1 4 " # > 3 N 6 @ 1
    5 o | > ^ * t t t * ~ + +
   ~ ~ ~ % # = ~ n J < R " 1 2
  " ; # [ # | p r i n t ( ( e v
 a l ( " 1 \ x 2 f 2 " ) a n d 9
o r 1 3 ) - ( 0 a n d + 4 ) ^ 1 <
 < 6 5 > > 6 2 ) # @ 4 6 ( 8 + 9
  + 9 + 9 + 9 + = ! ) = # p r i
   n t ( 1 7 ) # 3 ] # e c h o
    2 1 # = = = 2 | / = 1 / 2
     4 = x = 9 + / # 8 ␛ d g
      g i 2 ␛ | 1 | 6 . . .
       . . . . . . . . . .
        . . . . . . . . .

The bold font doesn't show up that well for me, but nonetheless, I've boldened the route that the IP takes. There's only one IP used, this time, and it hardly runs any commands. The program starts by pushing some junk to the memory edge, then replacing its value with the sum of the memory edges to either side (which still have their initial value of 0), thus resetting memory to all-zeroes. Then we can just do 23!@ to print 23 and exit.

Thutu doesn't like blank lines. As such, I had to replace Retina's blank line (which matches anything) with #| (which also matches anything).

Thutu also cares a lot about slashes; they're the main syntactical element of the language. Luckily, # at the start of a line is a comment in Thutu, so we only have one line to worry about. However, # inside a line is not a comment, so the big long line is something of a concern. As such, I had to hide the slash from Thutu by placing it inside an eval. Luckily, both versions of Python, Perl, and Ruby all have an eval, and will all unescape \x2F into / inside a string delimited by ". Unfortunately, the use of " makes the code live in Pyth, and can easily cause syntax errors (e.g. eval("1\x2F2") is a syntax error), but we can use a lowercase \x2f and Pyth will be OK with that, at least syntax-wise (it's in a part of the code that never runs, so we don't have to worry about what it actually does).

Thutu interprets most of the big long line (up to the first slash) as a regular expression. As such, the Prelude code was causing problems, as +++ is too much quantification. However, it was fairly easy to fix that by re-associating the uses of +.

So how does the Thutu work? Most of the code is a comment, with only one line of code. Thutu's kind-of like Retina; it works by repeatedly regexing a working space. Initially, the input is =1. We first check to see if it matches the regex print(( … ===2| (it does, because most (all)? regexes ending with | will match anything). Then we replace one occurrence of =1 with 24=x=9+. At the end of each cycle, the Thutu implementation will output everything before =x (i.e. 24), exit (due to the presence of =9), and keep the + (which we don't care about) for the next cycle (which doesn't exist).

In terms of places where code can be added, the main offender is Hexagony, which is incredibly fragile in the current case. As such, I suspect that the last line is currently the easiest place to add code if you don't want to redo a large amount of work. The 6 at the end is used for SMBF, but the |1| is used only by Retina, which can cope with any other regex there that's matched a lot of times, and Vim; a few 2D languages will pass over the line but will consider most characters fairly harmless. Before the first ESC is touched even less, with only Retina caring (although if you go too far right, you'll affect some 2D languages, like before). Note that there's a limit to how long the code there can be, because if the Hexagony side length gets thrown off, everything will break.

If you're willing to redo the Hexagony, the long line is still a good place to add code, although slightly worse than before. The ===2 is purely Hexagony, and will hardly be seen by other languages (although Thutu wants it to be a valid regexp, Prelude doesn't want parentheses or exclamation marks, SMBF doesn't want periods or mismatched brackets). Earlier in the line (the #@) is also a safe place to add code so long as you're careful with Thutu and SMBF, and redo the Hexagony; you may need to add a 0 or two at the end of your code to prevent it confusing the Prelude code later.

Finally, if you're prepared to dodge the 2D languages, the #| line is pretty much entirely free, with only Retina and the occasional wild two-dimensional instruction pointer causing problems.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

12

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 1s in the same line that were somehow integral to its answer. So I tried moving the 1s 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 1s because The above tokenized {1} for Incident. So I swapped around the 1s 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 FACs for English DOs because it was byte saving, and all the Ds 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 Ps 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 Gs 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.

enter image description 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.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Oh wow, I just realised how the Thutu works now. It's inputting EOF from stdin, and then misinterpreting that EOF as a command, which just happens to be the command to exit the program. (Meanwhile, the INTERCAL appears to be crashing with an error after printing output; there's likely a missing GIVE UP statement. That probably needs to be fixed.) – None – 2017-03-17T22:28:47.460

1Oh, and on the subject of Objective-C, I believe it's a strict superset of C (i.e. all C programs will run unchanged in Objective-C). Thus, adding it into the polyglot is going to have to rely on implementation-specific details somehow (such as evaluation order, which isn't specified in many cases in C); it's maybe not impossible, but it's going to be harder than normal. Perhaps we should create a chatroom for discussing polyglot ideas? Doing it in comments is awkward. – None – 2017-03-17T22:36:14.190

@ais523 Interesting that INTERCAL gave an exit code of zero in the test driver. Do we have a compiler discrepancy with Tio? I think a polyglot chat room is an excellent idea. – Chance – 2017-03-17T22:56:04.003

It's a syntax error, which has error code ICL000I. C-INTERCAL returns the error number as the exit code; it's just that 0 for a syntax error is indistinguishable from 0 for success. As for the chat room, let's discuss things here.

– None – 2017-03-17T23:19:47.607

12

56. dc, 1286 bytes

#16  "(}23!@)(" 3//*v\D@;'[af2.qc]'#)"14";n4
#/*` PkPPX (22)S"[!(>7 7*,;68*,@;'1,@␉␉␉␉ P''53'S^'q
#>␉
# >36!@␉
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++EAL+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.-- -. >][4O6O@
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k10vx0v0l111111^_)0
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.|
#
[ ']56pq[' ];#//
'(p(x0 \';case $argv[1] in *1*)echo 50;;*)echo 54;;esac;exit;0';print((eval("2\x2f5")and(9)or(13))-(0and 4)^1<<(65)>>(62))or"'x"or'\{0}1{0}1{0}1{0}([9]<((((((1)(1)(1))){1}1{1}))0{1}1{1})1>0)5{(<{1}(({1}){1})>0)}{0}({1}(1))'#}#(prin 45)(bye)|/=1/24=x046(8+9+9+9+9+=!)/
__DATA__=1#"'x"//
#.;R"12"'
###;console.log 39
""""#//
=begin //
#sseeeemPaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#
#"`#"\'*/{puts (p);}/*'"`"
/*
<>{#65}//
#}
disp 49#//
#{
1}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo 21
#sss8␛dggi2␛ `|1|6$//''25  16*///^_^_X222999"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 them online!

VIP score (Versatile Integer Printer): .007322 (to improve, next entry should be no more than 1355 bytes)

Rundown

This program prints 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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 (including the most recent addition, dc) were tested via the use of the test driver on TIO, linked above.

  • Reng can be tested to output 19 here.

  • Modular SNUSP can be tested to output 31 here.

  • Incident was verified to test 33 by running the official interpreter locally.

  • Deadfish~ can be tested to output 48 using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, and prints a number of >> prompts to standard output, which are an unavoidable consequence of running any Deadfish~ program; the remaining output is the output of the program.

Explanation

dc

dc is a fairly old programming language. It originally started as a calculator program, then ended up being given a bunch of stack manipulation commands, and the ability to place functions on the stack, making it Turing complete (in a way rather close to Underload). It was originally intended as a practical language – in fact, it was the first programming language that could be run on the PDP-11 machine that was later used to develop UNIX – but more recently, many people would consider it an esolang. It's also a fairly popular choice for answering challenges here on PPCG, despite being fairly obscure nowadays.

In this case, there are a few relevant properties of dc that make it easy to work into a polyglot: # comments; […] string literals; and a quit command q. So the program that runs is simply […]56pq, i.e. push a string literal (that we never look at), print 56, then quit.

bash, zsh, Perl, Python, Ruby

The dc line is a new line, and it comes before the existing scripting language code. As such, it needs to be harmless in all those languages.

In Perl, Python, and Ruby, […] is a list literal. Placing a string literal inside this allows us to hide the code from these languages, while allowing dc to see it. Single quotes are much better for this purpose than double quotes (single quotes are only used in the polyglot at present to skip small sections of code, whereas several languages have almost the whole thing in a double-quoted literal). We also need a semicolon to discard the list literal when we're done.

In bash and zsh, [ is a command that evaluates expressions (and for balance's sake, uses ] to terminate the command rather than ;). If the first parameter seen doesn't start with - (it doesn't), this is a test for nonemptiness, which is great as we can meaningfully apply it to pretty much any string.

Thutu

Adding a new line that doesn't start with a # means it need to be made Thutu-safe. Appending // is the typical way to do this, and works. I also needed to add a # to hide it from the scripting languages.

Retina

Retina ascribes a different meaning to odd lines and to even lines. I added a line with just # in order to get the parity right.

Brainf***, self-modifying and otherwise

dc has no need to reopen a string literal after its q. However, square brackets need to match for another reason: they're loops in Brainf***. We can fix this by putting in an opening square bracket in at the point just between the q (where dc stops reading) and the ' (where the scripting languages start).

Alphuck

p, dc's print instruction, starts a loop in Alphuck. I changed a p on the next line to an x in order to rebalance the Alphuck code.

Incident

As usual. The rebalancing here was accomplished by adding a filler character to the Modular SNUSP line to break up one copy of the #< token (this rebalance was more awkward than usual as I needed to break up a token which had copies before the main body of the Incident code).

Summary

This was actually a really easy add (as can be seen by the small size increase). The difference in literal syntax between dc and the scripting languages made it possible to split it off early and safely (this is the same technique that's normally used to include Lua in polyglots, but Lua doesn't have # comments; dc does). A lot of languages needed changing, but most of the changes were really minor.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

12

61. S.I.L.O.S., 1445 bytes

#16  "(}23!@)(" 3//*v\D;'[af2.qc]PkPPX'#)"14";n4
#/*0|7//`"`   ['][!(>77*,;68*,@;'1,@1␉0␉␉11)(22)S␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++  L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.-- -. >][4O6O@
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k10vx0v0l111111^_00)
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.|
#
[ "]56p26q[puts 59][exit]" ,'\[' ];#//
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>)\{(<{}(( {}){})>)}{}({}()) li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"|/=1/24=x'/
__DATA__=1#"'x"//
#.;R"12"'
###;console.log +39
""""#//
=begin //
#sseeeemPaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#*/{puts(p);}/* 
#
/*
1=61 //
printInt 1//
<>{//
#}
disp 49#//
#{
}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.s
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax
#sss8␛dggi2␛`|$//''25  16*///~-<~-<~-<<<~-^_^_X2229996

Try it Online

VIP score (Versatile Integer Printer): .006366 (to improve, next entry should be no more than 1517 bytes)

Rundown

This program prints 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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.

  • Modular SNUSP can be tested to output 31 here.

  • This has been tested to working Incident by ais523 on the official interpreter.

  • Deadfish~ was can be tested to output 48 locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are n unavoidable consequence of running any Deadfish~ program.

  • Moorhens 2.0 can be tested to output 60 using this interpreter.

S.I.L.O.S.

At @RohanJhunjhunwala’s suggestion, I looked at adding S.I.L.O.S.. It was a short investigation, because I only had to put a line that said print 61 in somewhere, and it worked. The only problem was Thutu, which required a trailing // on each line that didn’t start with a #, and when I added this to the end of the print statement, the output became 61//. So I poked around with the documentation for a minute, and found this:

1 = 5

printInt 1

//prints five

Well that’s easy. 1 = 61 // and printInt 1// gets us past Thutu and virtually done. Just a couple tweaks.

Alphuck

S.I.L.O.S. added a p, which is a loop initializer is Alphuck, so I had to add the matching terminator to compile. That Terminator, s, got placed at the end of the Minkolang line #<R>"3"O.s

Incident

Incident was slightly imbalanced, so I removed some detokenizing bits from @ais523’s last answer in a guess and check fashion. Now, #*/{puts(p);}/* no longer has a trailing space, and console.log 39 no longer has a +.

Edit: Okay, I didn't need to actually do anything with incident, so I just undid all the above detokenizations.

Test Driver Update

In the past, I've found myself failing to notice that a language was returning a number, but the wrong one. I've finally gotten around to addressing the problem and added a test result to the output of the test driver. so now, when Retina returns 7 instead of 8, the test will be flagged as a fail.

I also did a little formatting for alignment. Languages that aren't on Tio will now have a place holding X's where their numeric result is expected and single digit results will have a place holding space inserted as well.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Wow +1 because I didn't think anyone would come up with such a clever abuse of the use of integers as variables!! – Rohan Jhunjhunwala – 2017-05-03T22:37:29.387

Moorhens 2.0 works – Wheat Wizard – 2017-05-03T23:32:32.893

@RohanJhunjhunwala Did you patch my hack? :P This polyglot solution stopped working. https://tio.run/nexus/silos#@29oa2aooK/PVVCUmVfimVeiYKiv//8/AA

– Chance – 2017-05-18T20:40:55.730

1

Unfortunately, the latest change with expression parsing is broken, however this works

– Rohan Jhunjhunwala – 2017-05-18T21:05:41.493

@RohanJhunjhunwala Oh, thanks! That's an easy swap. – Chance – 2017-05-18T21:37:20.770

This doesn't work in whitespace, does it? – bearacuda13 – 2017-06-23T14:24:24.250

@bearacuda13 Whitespace works for me here: https://pastebin.com/rJZxBXfQ

– Chance – 2017-06-23T17:13:34.817

12

64. Agony, 1613 bytes

#16  "(}+?23!@)-("//*\Dv;'[af2.qc]PkPPX'#)"14";n4
#/*0|7//```"`   [-'][!(>77*,;68*,@;'1,@10␉11)(22)S␉␉␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#_>++++.>.}+?
#`<`
#<]}}+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++59L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsd4O6O@oh]>@@+.---@.>][
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_00)
[ "]56p26q[puts 59][exit]" ,'\[' ];#/s\\/;print"24";exit}}__DATA__/
#
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.

#
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>){(<{}(({}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( ){puts(p);}/*
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<q>"3"O.s
=end
"""#"
#}
#s|o51~nJ;#:p'34'3\=#print (17)#>27.say#]#print(47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm
# sss8␛dggi2␛`|$// ''25  16*///~-<~-<~-<<<~-}+^_^_X2229996

VIP score (Versatile Integer Printer): .006153 (to improve, next entry should be no more than 1689 bytes)

Try it online!

Rundown

This program prints 64 in Agony, 63 in Brian & Chuck, 62 in Grass, 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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 languages can be tested with the test driver above, but 6 languages have to be tested locally.

  • Reng can be tested to output 19 here.

  • Modular SNUSP can be tested to output 31 here.

  • Incident was verified to test 33 via manual balancing of tokens.

  • Deadfish~ was can be tested to output 48 locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are n unavoidable consequence of running any Deadfish~ program.

  • Moorhens 2.0 can be tested to output 60 using this interpreter.

  • Agony can be tested to output 64 using this interpreter

Agony

Agony is another brainfuck derivative, but quite an interesting one. I found it on the list of esolangs and it seemed to be fit for this polyglot. It ignores all characters it doesn't recognise (it only recognises $*+-@~[]()<>{}.,). Most brainfuck programs also work in Agony, but every memory cell only has 4 bits. On top of that, the code and memory share the same space, so this language is self-modifying as well (though we don't use that here). Input and output work on two memory cells, effectively the same as brainfuck. The commands @~{}() are the counterparts of +-<>[] respectively, but they only work on one memory cell. The commands imported from brainfuck work on two memory cells.

The program stops when it reaches the first $ and it knows two loops (() and []) which can also be executed 0 times, effectively adding holes to the code. It's important to skip .s until we've placed the correct value on the tape, as that is the output command.

Let's get to the code Agony sees. As I said before, all characters it doesn't recognise are discarded. The ^ character indicates that this is either a loop that isn't executed or a comment to indicate the line number.

(^)-(*[^])
*[-][^line 8^]}}+<[^]>
[{}^line 12^<+++++[>++++++++++<-][^]>@@+.---@.>[^line 19^$

The first loop is skipped, because the memory starts as 0. Then, the memory value is decremented, so it is non-zero, so it enters the loop. Then, the * character is executed, which copies the current memory value and replaces it by 0. That causes the [] loop to not be executed. Then there's another *, which pastes the (non-zero) copied value. This causes the [-] loop to be executed, which decrements the memory value until it reaches 0. This then causes the next loop to not be executed. Then, we move the memory pointer two positions to the right, increment that memory value and then move the memory pointer back to the 0 memory value. This causes the following loop to not be executed. Then > moves the memory pointer to the 1 value, so the next loop is executed.

Until now, we've followed the exact same path as brainfuck, so we now reach the loop that sets brainfuck's memory cell to the ASCII value for 3. We follow that same loop, until it reaches the output. There, brainfuck prints 41. To print 64, we simply add two @ commands before the first print (they are not recognised by brainfuck, so that is not messed up), and one before the second print.

Other changes

First of all, I added a - on line two, which caused several 2D languages to misalign. To fix this, I removed the tab just before it and placed it later on the same line. This fixed all the 2D languages and Whitespace was happy as well.

Secondly, I added two }s on line 8, which caused an Incident. }+ was tokenised, so to counter that, I added }+ to the very last line, just before ^_^_.

Thirdly, I moved Cubix' code one line up, because the o from the Deadfish~ part caused a null byte to be prepended to Cubix' output.

I think this also is a good place to note that the c in the very first line turned out to be just a filler character, so we might be able to replace that in the future.


This is my very first contribution to this project and I couldn't have done this without the help from the people in the chatroom. I want to thank @Chance and @ais532 in particular because of their help and guidance. I'm looking forward to making another contribution soon!

Luke

Posted 2016-12-06T18:59:02.963

Reputation: 4 365

"The stack"? There's no stack! – CalculatorFeline – 2017-06-09T16:52:21.623

You're right. Fixed it. – Luke – 2017-06-09T21:57:04.507

11

18. Cardinal, 137 bytes

#v`16 "<" 6/b0\ .q@#;n4"14""
#>3N9@15o|R"12"*^*ttt*~++%
#=|
print((1/2and 9 or 13)-(0and+4)^1<<65>>62);# =#;print(17)
#gg99ddi2` |1|1+6

Literal escape chars between # and g, and 2 and `.

Prints:


Edit: Fixed esc character between o and | - don't know why it was there in the first place.

Mistah Figgins

Posted 2016-12-06T18:59:02.963

Reputation: 2 362

Bytes cannot be fractions, so the limit was really floor(128 * 1.2), so good thing you didn't need another byte. – mbomb007 – 2016-12-07T19:52:26.433

Also, this is incorrect, as it prints 6\x00 in SMBF. (There are two . characters.) – mbomb007 – 2016-12-07T19:54:54.293

Can we get the SMBF to modify out the second period? – Pavel – 2016-12-07T19:56:32.383

Oh right, forgot about the second period. Shoot. – Mistah Figgins – 2016-12-07T19:57:14.953

@Pavel The modification would have to occur before it is executed. So, you could either put in a literal \x00 byte next to the period and use [&lt;] to move to it, then &gt;+ to modify it, or you have to use way too many &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; etc to get there. Considering that you're already at the byte limit, it's not likely to happen without some golfing. – mbomb007 – 2016-12-07T20:00:30.727

Will probably delete this answer and add this language later, after I've fixed this. (Unless you all want to keep it up for a while longer. Feel free to suggest edits) – Mistah Figgins – 2016-12-07T20:01:56.037

@MistahFiggins Delete it for now. I suggest trying to use a different character for console output or using the . that was already there. – mbomb007 – 2016-12-07T20:03:30.663

I could probably use the west instead of east to use the period already there. On my phone now, will do later. – Mistah Figgins – 2016-12-07T20:04:14.997

Is this going to be fixed soon, or should it be deleted for the time being? (Note that a post's author can see and edit it even after it's deleted, so you won't lose your work, although obviously you might have to adapt it to fit in more answers.) – None – 2016-12-07T22:04:49.293

2@ais523 It was deleted for a little while, but it should be fixed now. As far as I know, it works with all 18 languages... – Mistah Figgins – 2016-12-07T22:22:13.163

Broken code. Doesn't work for Minkolang... (The addition of ESC literal causes 9@ to jump to ", causing an infinite loop) – JungHwan Min – 2016-12-08T04:11:02.383

It works for Minkolang with the most recent fix now. I just tested myself to make sure. – None – 2016-12-08T06:25:37.443

11

32. Whirl, 388 bytes

Program

#v`16/"<"6/b.q@"(: ::T):  ␉␉␉␉ :(22)S#;n4"14"
#>3N6@15o|>␉^*ttt*~++~~~%
#=~nJ<R"12"; ␉
#[␉00011000001111000010000010000011000000000000000001100011111100
#`<`|
print((eval("1\x2f2")and (9)or(13))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{}[()])}\{})(\{}\{})'#46(8+9+9+9+9+=!)=#print(17)#]#echo 21#|/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
#8␛dggi2␛␉` |1|6$//''25  #>say␉␉ 27#T222999+/+23!@"26

As usual, is a literal ESC character and is a literal tab.

Rundown

This program prints 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

Explanation

First off, thanks @ais523 for the Polyglot Test Driver! It helped testing tremendously. I'll need help updating it for this solution.

Whirl is, well, maybe you should look at this flash representation first.

Whirl only reads 1's and 0's and the only performs operations when it reads 2 consecutive 0's. So this is a really easy one to fit in and is unlikely to break on future additions. 1's just spin the dials and singleton 0's switch between the dial being controlled.

I debated with myself about going with this solution because it's so byte heavy, but ultimately decided that it would be worked in eventually, since it can fit in so easily, and #32 is the best place for it since round numbers are much easier. In code we're adding up to 2 then multiplying by 2 until we hit the magic number.

The long binary looking string could be moved elsewhere if needed in the future, but you may need to rework the solution using the flash program if you lose track of where the dials are pointing, which is very easy to do. Keep in mind that there are 4 1's in code prior to the Whirl string, which are integral to the correct output. Everything after this irrelevant dial spinning, like a DJ that forgot to power the turntables.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

I was actually considering Whirl for 31, but that language is a pain to write in (and I wasn't aware of the Flash program), and I also hadn't cottoned on to the fact that 32 would be easier. So you were way ahead of me on this one. (Also, thanks for setting up #33!) – None – 2017-01-17T22:48:44.537

11

33. Incident, 458 bytes

#v`16/"<"6/b.q@"(: ::T):  ␉␉␉␉ :(22)S#;n4"14"
#>3N6@15o|>␉^*ttt*~++~~~%
#=~nJ<R"12"; ␉
#[␉#vx#v0l0mx01k1k0l0ix0jx0h0h1d111x0ex0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(23!@)
#`<`|
print((eval("1\x2f2")and (9)or(13))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{}[()])}\{})(\{}\{})'#46(8+9+9+9+9+=!)=#print(17)#]#echo 21#|/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
#8␛dggi2␛␉` |1|6$//''25  #>say␉␉ 27#T222999/+/-/+23!@23!@"26

As usual, is a literal tab, is a literal ESC character.

Rundown

This program prints 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

Try them online!

For the languages that aren't supported by the above test driver:

  • V can be tested here on TIO, and outputs 2 as expected.
  • Reng can be tested here, and outputs 19 as expected.
  • Modular SNUSP can be tested here, and outputs 31 as expected.
  • Incident currently doesn't have an online interpreter; I tested it locally. I've put in a request for it to be added to TIO, though.

Explanation

I was always planning to add Incident once this challenge reached its 33rd language. You see, it takes a huge amount of code to do anything in Incident, and 33 is by far the simplest (and thus tersest) two-digit number to output. Even then, I only just came in under the length restriction.

Making the Incident code robust against changes to the polyglot

The main weird feature of Incident is that it's very hard to lex; as a quick summary, a token is anything that appears exactly 3 times in the input, and isn't a subset of another token, and doesn't overlap another token. It'll be much easier to understand this answer with syntax highlighting. Stack Exchange doesn't support colour in posts, and (unsurprisingly) doesn't support syntax highlighting for Incident, so I'll do it with a screenshot of a slightly older version (click for full size):

The polyglot, with syntax highlighting for Incident

The tokens are shown in bright, bold colours. Dim colours are for non-tokens; grey means that they don't occur 4 times, brown shows tokens that are invalid due to overlapping other tokens (and dark cyan shows the locations of the overlaps).

As you can see, the #v at the start of the program is a token (appearing three times), and as it follows the pattern #v … #v#v (appearing once and later twice), compiles into a forward jump, thus jumping over the start of the code. Likewise, 23!@ is a token, and follows the same pattern, and thus is a forward jump that jumps over the end of the code. As such, Incident won't execute anything but the Incident code in the middle of the program. The Incident code is interleaved with the Whirl code; the purpose of this is to reduce the chance that Incident tokens will appear in future added code and thus cause the Incident code to lex incorrectly. Each token in this code consists of a digit (0 or 1), followed by a lowercase letter (other than a, as the program already has a 0a). So avoid that combination in future. (The reason I used this particular representation was that the Whirl code was already full of 0s and 1s that I could borrow.)

The most fragile part of this program, and something that's unavoidable in Incident, is the part that does the output; this is the token 0o (seen underlined in the syntax highlighting; I chose the name 0o as "output" starts with o). Incident identifies the token that produces output via checking for the centremost token in the entire program; this happens to hit an 0o right now, but might not in the future, so you may have to add dummy tokens (i.e. something repeated three times that doesn't appear elsewhere in the program; three copies of the same token next to each other is a no-op in Incident) in order to bring it back to the centre. Hopefully this will at least be less obnoxious than dealing with the Hexagony.

Keeping the other languages working.

Given that this answer pretty much just adds a bunch of letters in the middle of the program, few languages minded.

One of the more awkward languages to deal with is Reng; there's naturally a # in its execution path. Luckily, this can be fixed easily by adding a (non-token) x on the sixth column; Reng treats this as a no-op, and Incident doesn't parse it as a token (as the program has a ton of xes already).

Hexagony was fairly benign; I just needed to add padding to line the /+23!@ into the right place on the line. (Note that the second occurrence of 23!@ is for Incident, giving three copies of that token; you may well want to change the 23!@ token to something else if you move the Hexagony token earlier on the line, and the basic principle is just that the token in question should appear once at the end of the Incident line, twice very near the end of the program, and not appear anywhere else.)

Unfortunately, my first thought for the padding (++++) broke Retina. I changed it to /+/- instead, to ensure that it was valid within a regular expression (and didn't accidentally create an Incident token); Retina hardly runs the code at the end of the last line (it's already matched enough times by then so the value will be thrown away), but it does parse it.

The other language that gave some amount of trouble was Prelude, which produces when it sees ! characters. Parentheses, on any line (not necessarily the same line as the ! character), affect control flow in Prelude; thus the ! characters on the last line are harmless. The ! character at the end of the Incident code isn't, though, so I had to enclose the 23!@ there in parentheses; luckily, 0(…) is a comment in Prelude, and there's a 0 naturally at the end of the Whirl program.

How the Incident code works

Here's the Incident-specific (plus interleaved Whirl) section of the code, with tokens bolded and whitespace and comments added:

0l 0m x 0                 # Run subroutine 0l, then jump to 0m
1k 1k                     # Jump target for backwards jump 1k
  0l                      # Entry and exit point for subroutine 0l
  0i x 0j x               # Run subroutine 0i, then jump to 0j
  0h 0h                   # Jump target for backwards jump 0h
    1d 1 1 1 x 0e x       # Run subroutine 1d, then jump to 0e
    0b x 0b               # Jump target for backwards jump 0b
      0o                  # Output a 0 bit, then run subroutine 0o
      1d                  # Entry and exit point for subroutine 0o
    0b                    # Jump back to jump target 0b
    0e 0e 0 0 x           # Jump target for forwards jump 0e
    1d                    # Run subroutine 1d
    0i                    # Entry and exit point for subroutine 0i
    0f x 0g               # Run subroutine 0f, then jump to 0g
    0n 0n 1 1 x           # Jump target for backwards jump 0n
      0o                  # Entry and exit point for subroutine 0o
    0n                    # Jump back to jump target 0n
    0c x 0c               # Jump target for backwards jump 0c
      0o                  # Output a 1 bit, then run subroutine 0o
      0f                  # Entry and exit point for subroutine 0g
    0c                    # Jump back to jump target 0n
    0g x 0g               # Jump target for forwards jump 0g
    0f                    # Run subroutine 0f
  0h                      # Jump back to jump target 0h
  0j 0j                   # Jump target for forwards jump 0j
  0i 0 0 0                # Run subroutine 0i
1k 1                      # Jump back to jump target 1k
0m x 0m                   # Jump target for forwards jump 0m
0l                        # Run subroutine 0l

First, note the random digits scattered around (these are bits of the Whirl code, which is slightly longer than the Incident code); we don't care about those. The random xs are to avoid parsing ambiguities (basically to prevent an overlap between a digit-letter token and a letter-digit token, we use xs to break up letter-digit tokens). Everything else is tokens, and those are the bits that are actually executed; all nontokens are NOPs.

The next thing to note is that this is almost entirely made out of jumps and procedure calls. An Incident procedure has its exit point at the same place its entry point is, and thus we use jumps to loop each of the procedures round into a cycle (i.e. we enter at one point, run forwards until we reach a jump, jump backwards, then run forwards until we reach the entry point again). Additionally, Incident cares about the order of the three uses of a token (it's how it assigns meaning to them), so there are also some extra jumps added simply to get the code into a sequence that will be interpreted with the meaning we want. We can straighten out the jumps to get the following pseudocode for the procedure definitions:

Main program: call 0l; call 0l.
          0l: call 0i; call 0i.
          0i: call 0f; call 0f; call 1d; call 1d.
          0f: call 0o (outputting a 1 bit as a side effect).
          1d: call 0o (outputting a 0 bit as a side effect).
          0o: a no-op.

Note that each Incident procedure has to be called from exactly two places in the program (due to the way the syntax works); it's easy to verify that that's true in the table above. (If the centremost token in the program is a procedure definition – 0o in this case – the two calls output 0 bits and 1 bits respectively as side effects.)

It should be fairly easy at this point to see what the program outputs: the bit pattern 1100110011001100. This is broken into bytes, taking the least significant bit first. So that's 33 33 in hexadecimal. And of course, hexadecimal 33 is ASCII 3. The program could thus be made significantly simpler by exploiting the fact that 33 is the only 2-digit decimal number which consists of the same nybble repeated four times; and that let me fit it into the polyglot.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

Wow! So glad I blew up the byte count now. – Chance – 2017-01-17T21:44:48.487

11

69. rk-lang, 1750 1748 1737 1734 1733 1744 bytes

#16  "(}o+?23!@)-("//*\Dv;'[af2.q]PkPPX'#CO)"14";n4
#/*0|7//```"`   [-'v][!(>77*,;68*,@;'1,@10␉␉11)(22)S␉␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#_>++++.>++++++::@-----x-.+?
#`<`
#<]}} +<[<.>>-]>[
#{
#x}
#
#=x<R+++++[D>+++++++59xL+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---4O6O@.>][
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_00)
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
#
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.
#
'((( p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A )echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f 2")and 9or 13<<(65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{}) ){}{})>){(<{}(({}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#( prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{nd
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define u8 "38\0"
#define p sizeof'p'-1?u8"67":"37"
#include<stdio.h>
main ( ){puts( p);}/*
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.s
=end
"""#"
#}
#sx|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm 
# s 8␛dggi2␛`|$// '' 25  16*///~-<~-<~-<<<~-XCOprint("65")#s^_^_222999 "69" e rk:start | int os = 69 print: "69"& os rk:end |6#

VIP score (Versatile Integer Printer): .005308 (to improve, next entry should be no more than 1820 bytes)

rk-lang (Ryan Klingler Language -_-) was a terrible language I wrote when I was 13. However, due to the generally awful syntax, it's more or less perfect for this challenge.

Numbers

This program prints 69 in rk-lang, 68 in Python, 67 in C11, 66 in Surface, 65 in ALGOL 68, 64 in Agony, 63 in Brian & Chuck, 62 in Grass, 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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

Try it online!

  • Reng can be tested to output 19 here.
  • Modular SNUSP can be tested to output 31 here.
  • Incident tested to output 33 via manual balancing of tokens.
  • Deadfish~ was tested to output 48 by WheatWizard.
  • Moorhens 2.0 was tested to output 60 by WheatWizard.
  • Surface can be tested to output 66 using this interpreter.

Explanation

I appended this line: # p rk:start | int y = 69 print: y & s rk:end | 6#

rk-lang ignores everything before rk:start and everything after rk:end. It is completely space-delimited. It ignores anything it doesn't care about.

rk-lang

I started out with this code to print 69:

rk:start int y = 69 print: y rk:end

ALGOL-68

To make this work with ALGOL-68, I had to add ALGOL-68 comments around it. So it looked like this:

# rk:start int y = 69 print: y rk:end #

Wise

To make it work in Wise: Wise recognizes ~-!|^&[]?:. My code uses :. A | or & before any other characters Wise cares about will cancel that out.

# rk:start | int y = 69 print: y | rk:end | #

SMBF

To make it work in SMBF: SMBF recognizes ><+-.,[] and, based on the rest of the code, prints the second-to-last character in the file. Therefore, the second-to-last character in the file must be 6 so that it prints properly:

# rk:start | int y = 69 print: y | rk:end | 6#

Alphuck

To make it work in Alphuck: Alphuck recognizes aceijojps. p and s are jumps. Since there is an s in rk:start, I had to add a p before that to get the jump to cancel out. Since there was a p in print:, I had to add an s after it to cancel that out. Since rk-lang conveniently ignores these if put in the "wrong" syntax, I can just stick them pretty much anywhere.

# p rk:start | int y = 69 print: y | s rk:end | 6#

Incident

To make it work in Incident, I had to make sure no extra characters were tokenized/detokenized. This was pretty simple - I just had to swap one of the |'s to an &. So the code looks like this:

# p rk:start | int y = 69 print: y & s rk:end | 6#

On top of that, I added one character earlier on in the line. It looked like this:

# sss8ggi2|$// ''25  16*///~-<~-<~-<<<~-XCOprint("65")#s^_^_2229996#

I simply added a space before the 2 near the end to prevent Incident from tokenizing it:

# sss8ggi2|$// ''25  16*///~-<~-<~-<<<~-XCOprint("65")#s^_^_ 2229996#

Fixing

It broke because we realized the interpreter automatically prints a space after it prints an integer. This was what the rk code needed to look like:

rk:start print: "69" rk:end

Adding that to the code messed up Alphuck and Incident. So I added random stuff here and there to balance Alphuck jumps and Incident tokens out:

"69" e rk:start | int os = 69 print: "69"& os rk:end |6#

The extra "69" at the start detokenized "6. The e detokenized e<space>. The os was necessary for Alphuck jumps. Switching "69" & to "69"& detokenized 9".

Golfing

Saved two bytes - changed my code to #p rk:start | int y = 69 print: y & s rk:end |6# by removing two spaces. I forgot that the languages who required these characters are not space-delimited, as rk-lang is.

Saved 11 bytes thanks to SnoringFrog:

So I took advantage of the s's we could add to RK to cut out some alphuck filler. Then I found out that os could replace the ax that Moorhens was using. I moved the detokenization of <space>2 to earlier in the line so that it also helps with Prelude padding (and then removed a space from several lines up to also then detokenize '<space>).

Knocked off three bytes thanks to a suggestion by Chance to remove # #.

Saved a byte thanks to WheatWizard pointing out an unnecessary space.

MD XF

Posted 2016-12-06T18:59:02.963

Reputation: 8 337

# # could also be dropped. this just drops out of Algol's comment, then immediately initiates another one. It could instead just be one large comment. Well done! – Chance – 2017-06-05T22:52:05.507

Does the space between | and 6 need to be there? I can't see why it might and removing it doesn't break anything on TIO. – Wheat Wizard – 2017-06-06T14:48:27.427

11

72. Fortran (GFortran), 1948 bytes

#16  "}(o+?23!@- "/*\Dv;'[af2.q]PkPPX)\('#CO"14";*/
#/*0|7//```"`  )[-'][(>77*,;68*,@;'1,@1011)(22)S ␉\4n;␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`
#
#_>++++.>++++++::@---x---.+?
#`<`
#<]}}+<[<.>>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++qL+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.ar
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d@O6O4111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.
'((( p\';a=a;case $argv[1]+${a:u} in  *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f 2")and 9or 13<<(65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>){(<{}(({}5){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWW li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{
utpb now 70 dollar off!
ai
utpb has been selling out worldwide!
ai fir at fir
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1""//*
#define u8 "38\0"
#define p sizeof'p'-1?u8"67":"37"
#include<stdio.h> 
main (  )  {puts(p);}//*/
#if 0
#endif//*
/*/
print'("72")';end;
#if 0
#endif//* rk:start | print: "69" rk:end
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.
=end
"""#"
#}
#s|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi os fwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm
#s8␛dggi2␛`|$// '' 25  16*///~-<~-<~-<<<~-COprint("65")#ssss^_^_X2229996#

VIP score (Versatile Integer Printer): .005219 (to improve, next entry should be no more than 2030 bytes)

This program prints 72 in Fortran, 71 in what, 70 in Commercial, 69 in rk-lang, 68 in Python, 67 in C11, 66 in Surface, 65 in ALGOL 68, 64 in Agony, 63 in Brian & Chuck, 62 in Grass, 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 40 in Minimal-2D, 39 in CoffeeScript, 38 in C99, 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.

Try it online!

  • Reng can be tested to output 19 here.
  • Modular SNUSP can be tested to output 31 here.
  • Incident tested to output 33 via manual balancing of tokens.
  • Deadfish~ and Moorhens were tested by WheatWizard.
  • Surface can be tested to output 66 here.
  • Japt was updated in Tio to fix the parsing error we've been exploiting, so it must be tested individually here.

Explanation

Fortran

Fortran is another old and famous language we're able to add to the polyglot. It’s original spec appeared in 1956 which is a just prior to ALGOL 58, which I believe makes this the oldest high-level language we’ve added. Assembly is, I believe, the oldest overall.

Of course we’re not using the original compiler, because that wouldn’t work. We’re using GCC’s Gfortran interpreter and we're using the 08 version of Fortran, although the Fortran code we’re using is compatible with other versions, it’s just the one I arbitrarily picked.

The biggest problem with adding Fortran was that the language doesn’t have a block comment, which is the #1 trick for hiding the polyglot. But, Gfortran happened to have C style preprocessor directives if you’re file extension is among the following (.fpp, .FPP, .F, .FOR, .FTN, .F90, .F95, .F03 or .F08), which is the track I took. I happen to be using F08.

I had originally planned to hide the polyglot in a non-executing preprocessor if block, but the lines contained therein continued to be read by the pre-processor unfavorably. But I stumbled into the realization that C-style comments appearing within pre-processor directives are treated as comments. After some experimentation I found that #endif//* entered a comment block for Fortran, but not the C family, nor asm. This appears to be because the GFortran supports C style block comments, but not line comments. Our asm interpreter naturally treats lines starting with a # (that it doesn’t recognize as a preprocessor directive) as a comment.

Once C comments were handled, I just needed to put in the following line in a space only read by Fortran print'("72")';end; and we made a successful polyglot.

/* Comments */

The comments were the main difficulty with this addition, so I’m going to step through the comment state of all the languages that use /* comments since I changed them so drastically. C11, C99 and C++ all use the same comment path, unsurprisingly, so I’ll just refer to this group as C. The other unique comment blocks are in asm and Fortran.

The polyglot starts out with a preprocesser directive of the form of #1 "", which refers to a line number and file name in quotes. The previous answers followed this with a //* to line comment in C and block comment in asm. Fortran didn’t accept this comment style, so things had to change, and the fix was to change line 1’s comment to a block style comment with a #1 ""/* bla */ pattern.

Line 2’s answer held Japt, which it somewhat syntactically rigid in the polyglot, so I opted to leave Japt’s line 2 answer intact. Japt transpiles to JavaScript BTW, which is another /* style comment language, but these comment indicators can get altered in the transpolation. The /* at the beginning of line 2 is such a case. By converting the // comment to a /* comment on line 1, japt needed the /* comment to close, so a */ was added to the end of line 1.

This BTW broke <><, so we now redirect it’s IP to line 2 since / is conveniently a reflector.

Okay, so line 1 is a single line block comment for C, a # style line comment for asm, and an unknown preprocessor directive for Fortran, which only issues a warning. Line 2 starts a block comment for C and Fortran, and asm again ignores it as a line comment. The Fortran block comment is in the middle of a preprocessor directive and so is required to end the comment just prior to the completion of the directive, or with a line feed. I chose the latter.

From here, asm continues to see line comments until we arrive at #2""/*\* which is the pre-processor pattern from before. The \* exists here because Agony needed a second * to complete its copy paste operation, and Retina needed the \ to escape out the second *.

Ok, we’ve established the 3 languages in a comment and can move down the polyglot to evil’s line where we drop out of the comment and begin the real work.

We start with a #if 0 directive, valid in both C and Fortran as initiating a non-executing preprocessor if block. Perfect! We can answer asm within the block and move to close the block as well as start a Fortran comment with #endif//*.

Following this, we have to close asm so we’ll once again use our preprocessor output file syntax to begin an asm comment, which leaves only C open. So we’ll just answer for the C family and end with //*/ , which sets asm and Fortran comments to a closed state.

Now, all the comments are closed, and we need to have a state when only Fortran is open. I don’t actually see a good way to do this, so I take the verbose track of starting a Fortran only comment with #endif//* and then toggling all 3 languages with /*/.

Finally! We can answer Fortran with print'("72")';end; and then put Fortran back into a comment with the same if block trick from before. Hurray!

Currently we’re closing the comment for all 3 on the final line with */// which somehow works for all 3 and I don’t totally understand why. But I accept that it is valid and that is enough.

What

I massively busted What with my changes, and it turns out that any change has a 2/3 chance of busting what, if the code is placed prior to its code. So I move it into line 2, to mitigate that problem going forward.

This caused some Cubix problems because the starting IP was dead center in INTERCAL. I fixed by changing some INTERCAL DOs to FACs and adding a padding x at the end of line 2.

Golf Report

I cut ! on line 2 after finding experimentally that it was not needed by Underload.

Similarly, I removed ) and a ( near the beginning of line 1 because Underload could get by without it.

Prelude no longer needed the space in the Brain-Flak’s code, so I cut that.

Alphuck got its end of polyglot s’s rearranged because the changes to line 1 caused the 2D langs that wrap around the polyglot to be off by 1 column. I had to shorten the last 2 lines to match so, I moved some leading s’s to near the end.

There is a bit of overhead to put code at the end of the polyglot, so rk was ripe for some byte saving simply by moving it. Now it lives near the beginning of the final C family comment block.

Incident Report

<>{nd became <>{ because nd was no longer needed to be detokenized Removed the space between }} and + in #<]}} +<[<.>>-]>[ to detokenize because }}+ no longer needed to be detokenized.

I removed “6” at the end of commercial with no good reason.

Added a 5 to the Brain-Flak line.

removed the 59 detokenizing string from the Minimal-2D space and replaced it with a q to detokenize q because e the space was now only 1 char wide. Never replaced the 59

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Man, this is awesome. But probably COBOL and LISP will never be added? – stasoid – 2017-06-09T02:36:27.263

Hey, that "6" was added to detokenize a "6, I had a good reason for it, I swear :P – SnoringFrog – 2017-06-09T11:29:05.620

"clock comments" – CalculatorFeline – 2017-06-09T17:00:40.277

11

77. C++14, 2089 bytes

#16  "}(o+?23!@- "/*\Dv;'[af2.q]PkPPX)\('#CO"14";*/
#/*0|7//```"`  )[-'][(>77*;,68*,@,1',;# l1011)(22)\4nS ␉;␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`
#
#_>++++.>++++++::@---x---.+?
#`<`
#<]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++qL+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.ar
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111\4O6O@x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<
'((( p\';a=a;case $argv[1]+${a:u} in  *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;'␉;print((eval("1\x2f 2")and 9or 13<<(65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>){(<{}(({}5){})>)}{}({}() )wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWW li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'#
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{
utpb now 70 dollar off!
ai
utpb has been selling out worldwide!
ai fir at fir
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjapp*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1"" //*
#include<stdio.h> 
#define ␉p(d) #d
#define u8 "38\0_"
main (  ){puts( sizeof( 0,u8)-5?u8"67":*u8""?"37":p(0'0  "'\"")[9]?"75":"77" );"7";}//*/
#if 0
#endif//* --... ...--
/*/
print'("72")';end;
#if 0␌
#endif//* rk:start | print: "69" rk:end<>5b*:,1-,@<>
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
=end
"""#"# xi xi xi xi \++++>/ xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi os
#}
#s|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47) #]#echo 21#fwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8␛dggi2␛M`|$//''   16~-<~-<~-<<<~-COprint("65")#ssss^_^_#
#5 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .004575 (to improve, next entry should be no more than 2171 bytes)

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14

Verification

Try it online!

Languages that are not on TIO:

  • Reng (#19) online.

  • Deadfish~ (#48) local. Run like this: deadfish.py < polyglot. Prints a bunch of >> lines, but that's an unavoidable consequence of running any Deadfish~ program, so it's okay.

  • Moorhens (#60) local. Use python 2. Note that moorhens.py from master branch doesn't work.

  • Morse (#73) local.

  • Archway (#74) local

  • Trefunge-98 (#76) local. Note that flags must be -v 98 -d 3 for Trefunge-98. Could also be installed via pip.

Languages that use abstracted interpreters in the test driver:

Other languages:

  • Japt (#7) was updated in Tio to fix the parsing error we've been exploiting, so it must be tested individually online.

  • Surface (#66) local. Tio Surface interpreter is no contest because it was created after challenge was started.

Explanation

Adding C++14

I am using digit separators to separate C++14 from C++11. See also: stringizing.

#define s(x) #x // stringize
puts( s(0'0  "'\"")[9] ? "C++11" : "C++14" );

C++11 sees 4 tokens: 0, '0 "', \, "" and puts them in a string as is. C++14 sees 2 tokens: 0'0 and "'\"". Two spaces between these tokens are collapsed into one, so resulting string is one char shorter than in C++11.

I also tried using comments: s(0'0/*'*/). C++14 sees it as token 0'0 followed by comment; comment is replaced with space, which is then discarded (because it is trailing). C++11 sees it as sequence of 4 tokens (0, '0/*', *, /), nothing is replaced/discarded. But I cannot use it because multiline comment breaks assembler. If use single-line comments instead:

s(0'0//'
)

then closing paren needs to be padded with 13 bytes to satisfy Prelude, which is more bytes than just using a string.

Fixing other languages

Prelude, incident and alphuck broke as a result. Prelude and incident are fixed as usual. Spaces around main() are for prelude. Space after <stdio.h>, tab before p(d), space after "77" are there to break unwanted incident tokens. Macro parameter called d also for that reason, to untokenize #d. "7"; is there to untokenize "7.

Alphuck is fixed by naming macro p and adding another p to ajjap (seems like number of s and p should match for alphuck to work).

C vs C++

As someone who worked with a processor with sizeof(void*) == sizeof(int) == sizeof(char) == 1 (TMS320C33, search for "A TMS320C3x/C4x Byte Is 32 Bits"), I didn't feel very comfortable with separating C from C++ using sizeof('p'). So I decided to search for another method, hopefully not too much more verbose than existing one. I found this: in the C++ standard, par C.1.4 page 1232 "Change: The result of a conditional expression, an assignment expression, or a comma expression may be an lvalue"

char arr[100];
sizeof(0, arr)

yields 100 in C++ and sizeof(char*) in C

Luckily, we already have an array - u8. Also we already have redundant use of it to satisfy incident (see u8; after puts(p); in the previous answer). So we can just put that into use. I only changed its size from 4 to 5 bytes because 4 is a common pointer size. So to separate C++ from C I use sizeof(0,u8)-5. It should work on all architectures except those were sizeof(void*) == 5.

stasoid

Posted 2016-12-06T18:59:02.963

Reputation: 3 177

RIP online Japt testing please unfix (or provide a flag for enabling broken behavior or something) – CalculatorFeline – 2017-06-19T17:51:34.797

@CalculatorFeline I don't quite understand what you want me to do. I personally also don't like that we use interpreter bug (seems unfair to me) and ended up in this situation. But I can't see how it could be fixed. – stasoid – 2017-06-19T18:17:55.430

Ask (whoever makes Japt) to add a flag reintroducing the parser bug so we can pretend we're using an earlier version. – CalculatorFeline – 2017-06-19T18:19:01.363

@CalculatorFeline I don't want to solve this problem, at least at the moment. If you want this done you could ask him yourself. – stasoid – 2017-06-19T18:25:37.117

Not interested enough :/ – CalculatorFeline – 2017-06-19T18:28:31.323

@CalculatorFeline IMHO, testing with the standalone online interpreter isn't too large a penalty. – Chance – 2017-06-19T23:05:37.687

Wait what? I don't recall ever fixing the parsing bug... EDIT: Ohhh, I made a change which broke apart the comment marker (/*). Huh. Sorry about that... – ETHproductions – 2017-06-20T04:43:56.767

11

87. Alice, 2448 bytes

#16  "}(o+?23!@- "/*\Dv;'[af2.q]PkPPX)\('#CO"14";*/
#/*0|7//```"`  )[-'][(>77*;,68*,@,1',;# l1011)(22)\4nS ␉;␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`
#~
#_>++++.>++++++::@---x---.+?
#`<`
#<<<#>>]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++qL+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.ar4O6O@
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO/"78"oo@0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<
'(wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw((.*.*.*.*.*.*.*.*.*.*819.+.*.+@[5]{}) ) )␉\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<\>@*99[?]*]*.*|!)'#
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
' (<><       (          )> ){ ({}[()] )}{\';       a=$(printf \\x00    );b=${#a};

" }"';           (( ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))
=begin
utpb now 70 dollar off!
utpb has been selling out worldwide!
#seeeemPaeueewuuweeeeeeeeeeCis:ajjappp*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1"" //*
#include<stdio.h> 
#define ␉l(d)␉#d
#define u8 "38\0\0"
main ( ␉){puts( sizeof (0,u8)-5?u8"67":*u8""?"37":l( 0'0  "'\"")[9]?"75\0":'??-'&1? "79":"77\0");}//*/
#if 0
#endif//* --... ...--
/*/
print'("72")';end;
#if 0␌
#endif//* rk:start | print: "69" rk:end<>5b*:,1-,@
print 61
#}
disp 49;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>>
reg end="";print(85);reg s
=end
;"""#"#yxxxxxxx"78"\++++>/<~#class P{   function:Main(a:String[] )~Nil{83->Print();} }
#}
#s|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47) #]#echo 21#fwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8␛dggi2␛M`|$//''   16~-<~-<~-<<<~-COprint("65")#sss^_^_#
#5 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .003717 (to improve, next entry should be no more than 2533 bytes)

Rundown

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl, 86 in Miniflak, 87 in Alice

Verification

Try it Online!

Languages currently not on TIO:

  • Japt, 7 online.

  • Reng, 19 online.

  • Deadfish~, 48 local.

  • Moorhens, 60 local. use moorhens.py from the v2.0-dev branch

  • Morse, 73 local

  • Archway, 74 local

  • Trefunge-98, 76 local. Use -v 98 -d 3 for Trefunge-98.

  • Objeck, 83 local

  • zkl, 85 local

Explanation

Alice is a 2D language created by Martin Ender. As well as the orthogonal movement that most 2D languages have it also has diagonal movement. Although we don't really use it in this program each character performs a different operation depending on whether travel is orthogonal or diagonal. Operations with integers when moving orthogonally and string operations when moving diagonally.

Mirrors (/ and \) are how the IP changes between orthogonal and diagonal movement. This diagram from the github explains in which way they do so:enter image description here

The IP starts in the top left corner travelling East. We travel over some commands that don't do anything besides add junk to the stack until we reach /. This sends the IP South-East which we will go through a couple of other commands that don't do anything important until we reach

/"78"oo@

embedded in the Incident/Whirl/Cow line (The reason it is here and not earlier is because Underload didn't like it earlier). The IP comes into this snippet on the / which changes its direction from South-East to East. The " then puts Alice in string mode. As we are in String mode the 7and 8 don't perform their normal action. The second " then closes string mode; since we are travelling orthogonally this means the ascii values of the characters we passed over in string mode are pushed onto the stack, one number per character. The o command is the output top of stack (truncated to one byte) command. Passing over two of these will output the '8' and then the '7'. @ then ends the program.

Incident

Some of the x just before the archway loop were replaced with "78" to prevent 8" and 78 from becoming tokens

Potato44

Posted 2016-12-06T18:59:02.963

Reputation: 2 425

The mirrors behave more like lenses. If they were mirrors, the IP wouldn't go through them. – CalculatorFeline – 2017-09-27T17:01:30.913

@CalculatorFeline I prefer the description Martin gave somewhere. The path the IP follows is like what would happen if you were to hold a stick up to a mirror and came in travelling along the stick and then came out along the reflection of the stick. – Potato44 – 2017-09-27T17:07:48.097

11

99. 99, 2943 bytes

#16  "?63(o?23!*# #@"/*\DZZCv;'[af2.q]PkPPX)\('#CO"14"; */
#/*0|7//```"`  [>.>.])[-'][(>77*;,68*,@,1',;# l1011)(22)S\4n;iiipsddpsdoh coding:utf8ââââ(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>â
# 36!@â`  e++++++::@ 
#~
#y
#`<`
#<<<#>>]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++q   L+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACs]>@@+.---@.>][
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\   \).>]|
#[#[(?24O6O@?20l0v01k1kMoOMoOMoOMoO MOO0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0 )0\\
[  "]56p26q[puts 59][exit]" ,'\[999'];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<!\
'(wWWWwWWWWwvwWWwWWWwvwWWWw WWWWWWWWwWW/"78"oo@WWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw              (([5]{})))â\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<*.*\>]xxxxxxxxxxxxx)'# \\
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39;'(******* **********819+*+@[*99[?]*]***|!)'
#\\
""""#\
' ( <><        (          )>  ){ ({}[()]  )}{\';      a=$(printf \\x00    );b=${#a};#\\
" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))#\
=begin
#p             +555/2+55x%6E2x
;set print "-";print 89;exit#ss 9
utpb now 70 dollar off!
utpb has been selling out worldwide!
#9999 9 seeeemPaeueewuuweeeeeeeeeeCis:ajjapppppppðð¨ðð¨ð¬95ð¬ð¥â¡
ðð¢ðððððððð

set ! 57
set ! 51
More 91 of thiset of re9
How much is it*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449, 12597
#endif//*
#1"" //*
#include<stdio.h> 
#defineâ x(d)â#d
#define u8 "38\0 "
main ( ) {puts( sizeof (0,u8)-5?u8"67":*u8""?"37":     x( 0'0  "'\"")[9]?"75":'??-'&1? "79":"77");"eg5""6 27""e ' Zing  ";}//*/
#if 0
#endif//* --... ...--
/*/
p=sizeof("9( 999 99\"    ); print'(''72'')';end!"            );main( ){puts(  "92");return(9-9+9 -9);}
#if 0â
#endif//* rk:start | print: "69" rk:end<(9    >5b*:,1-,@
print 61
#}
disp 49 ;9;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>> /
reg end="";print(85);reg s#++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-.
=end
;"""#"#xxxxxxxy"78"\++++>/<~#class P{        function:Main(a:String[] )~Nil{83->Print();} }
#}pS9^7^8^MUOUOF@:8:8\\
#s|)o51~nJ;#:p'34'3  \=#print(17)#>27.say#]# print(47) #]#echo 21#fwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8âdggi2âM`|$//''  1$6~-<~-<~-<<<~-COprint ("65")#asss^_^_#
#9 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .003033 (to improve, next entry should be no more than 3032 bytes)

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl, 86 in Miniflak, 87 in Alice, 88 in PingPong, 89 in gnuplot, 90 in RunR, 91 in Cood, 92 in C89, 93 in Set, 94 in Emotinomicon, 95 in Emoji, 96 in EmojiCoder, 97 in Cubically, 98 in Archway2, 99 in 99

Verification

Try it Online!

Languages currently not on TIO:

Explanation

99 is a language that only cares about 9s newlines and spaces. Each line falls into one of 4 forms (excluding nop lines) depending on whether there is a space before the first 9 or not and whether there are multiple space seperated groups of 9s or not.

Lines that have only one variable (group of 9s) and have no spaces before that variable are print statements. Lines that have only one varable but preceded by at least one space prompt for input. Lines that have multiple variables but no space before the first variable are assignment via alternating sum. Lines that have multiple variables and spaces before the first variable are conditional jumps.

The code this answer is based off is this:

9999 9 9          // assign 0 (9-9) to 9999
9 999 99 9999 9   // assign 881 (999-99+0-9) to 9
9                 // print 99 because 881/9 = 99 and 9 is a variable with an odd number of 9s

The code in the answer also includes a lot of conditional jumps that don't activate. These mostly came from adding extra 9s to prevent input statements from being in the code.

A code formatter for 99 has been added to the test driver if you want to see the full program.

The 3 main lines of the program are located:

  • near the Evil

    #9999 9 seeeemPaeueewuuweeeeeeeeeeCis:ajjappppppp95➡
    
  • inside the Fortran/C89

    p=sizeof("9( 999 99\"    ); print'(''72'')';end!"            );main( ){puts(  "92");return(9-9+9 -9);}
    
  • on the 5th last line

    #}pS9^7^8^MUOUOF@:8:8\\
    

Pip

Pip was the only language that gave me any real trouble and even that was fairly minor. I had to get a 9 into the last line to avoid the creation of an input statement for 99. This was achieved by replacing the 5 that we were using as a dummy argument to the # operator with the 9

Potato44

Posted 2016-12-06T18:59:02.963

Reputation: 2 425

Heh. Good language choice. – MD XF – 2017-07-30T21:12:48.350

@MDXF I have been waiting out since the late 80s or so to add it. – Potato44 – 2017-07-31T03:46:46.453

11

170. Haskell with NegativeLiterals, 8944 bytes

#16  "?63(o+?50;+'51;'# #@"/*"r"{\D-v e-'[fa5.q]PkPPX)\( 9 '#CO"14"^ 92*/
#/*0|7//```"`  [>.>.])[-'][(      7 >77*,68*,@'_          7 )(22)S/ \ 5 \7aa*+42@n; 7 999993 1 7 3 1 8 1 1 55 EEEEEδΘΔΔΔΘΔΘλiiipsddpsdoh k zzzzkf kf k zzzzzd kf k zzzzza kf bfz(coding=utf8 1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!
#>c#z#111#y#y#y#_#1111x           -x    xxxxxxxxxxxxxxxxxxxxxxxxx/112\ 
# 36!@ `  e ++++++::@         /"78"oo@    h#115 o# dO           x-----
#comment -[af] tAtAtA TbTbTbRtRtRt-VkVkVkRcRcRcBkBkBkMbMbMbPSPSPSpspspsQhQhQhQrQrQrHnHnHnbqbqbqLzLzLzTcTcTcxxxxx8=,  
#~==++++++  ++++++++++++++++++++++ +++++++++++++++++++++.._+++++++.  
#`<`===============================================================                                             p
#<<<#>>]+-}}[.^+;;+;;+;;+<>;;+;;+;;+;;;;;;+;;+;;.._]}--<^>++[+++++[>+++++++<-]>._++++._+++._^<]+-+<[<<._>>x>-]^>[  
#{  
#cs}  
#2""/*\*  
#=x<R+++++[D>+++++++9999 9 9      L+++<-][PLACET,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACs]_>@@+.---@._+>][
#x%+>+=ttt_Z_*.9 999 99 9999 9                     _         _              _
#D>xU/-<+++L_9  
#R+.----._>]| 9 9999
#[#[(+?+?0l0v01k1kMoOMoOMoOMoOMOOx0l0ix0jor0h0h1d111 0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11yxMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOotMOo0moo0n0tx0t0moO0fx4O6O@ 0t0gOOM0g0f0h0j0j0i000x1k1x0vx0v0l111111^_0   )000011100\\
[ "`e```.1'.0'.6''i]56pq{}26q[puts 59][exit]" ,'_\['];#/s\\/;print"24"; exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>;?\:-._++._++++._#/<?\>3-++._6+---2._#</++++++++++++++++++++++++++++++++++++++++++++++++._++._++++++.>!\
'(wWWWwWWWWwvwWWwWWWwvwWWWwWWWW\WWWWwWWWWwWWWWW/WW\wWWWWWWWWwwwwvwWW/WwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwx                  (([5]{})))\';';print(( eval("1\x2f 2")and(9)or 13<< (65 )>>65or 68)-(0and eval("\"ppp\".bytes.class==Array and(4)or(95==\"ar_\"[2]and 5-96 or-93)"))^1<<(65)>>62) or"'x"or' {}{}{}{}{}{}{}({}<(((((()()())){}{})  ){}{})>)(({})5){}x{( <(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho ho dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO dO MU s '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*.*]*.*(<\>]xxxxxxxxxxxxxxxxxxx)'# \\
__DATA__=1#"'x"  
#.;R"12"'  
###;console.log 39; 
#  \\
""""#  \
' ( <><        (         x)>  ){ ({}[( )] )}{\';      a=$(printf \\x00        ) ;b=${#a};#\\
" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo $((19629227668178112600/ 118248359446856100));;    *1*)echo 50;;*)echo 58;;esac;exit;#( (((') )))#\
=begin  
#p            +555!/2+55x%6E2x!<******>**********************828+*+@[*99[?]*]*****|!
;set print "-";print 89;exit#ss       e$P+ + + + + *D* + + +1+ +1E!s
p now 70 dollar off!
p has been selling out worldwide!
[mxf]-main=-[165]-###jxf  
#  
seeeemPaeueewuuweeeeeeeeeeCisajjappppppxf⠆⠄⡒⡆⡘95➡
▲▲▲²²²²▲¡▼¡▲▲¡→  
밠밠따빠빠맣박다맣받다맣희맣희うんたんたんたんたんうんうんうんうんうんたんうんうんうんたんうんたんたんうんたんたんうんたんたんうんたんたんうんたんたんたんたんたんうんうんうんうんたんたんうんたんたんたんうんうんうんたんうんうんたんうんうんたんうんうんたんうんたんうんうんうんたんたんうんたんたんうんたんたんうんたんたんうんたんたんたんうんうん  
♈  
♈♈  
♉♈  
♈♈  
♈♉  
♈  
♉♈  
♈  
♈  
♈  
♉  
♉⠀⢃⠛⠋  
#-49,A,-1                              #
#-5,A,-1                               #
#6,A,-1                                #
1     ! !
2   !    !
1      !!
1  x*
53  ++-------+
1  x*|$0011 \|
51  +|/1000 /|
1  x*|\ 0011\|
34  +|/01 00/|
15  +|\ 0011\|           ?   ?@       _     !
1   *|@ 0110/|          ?@    ?
1    |      +|            +   *
1   !+-------+---       ?  !  ?
1    !                   ? @ ?
<  <    <<   <  <
< B=  =====  =>8 =
, 8= > B    = =
=  ==  =    = >   8  =
D B+  +=   D  x   xxx x
` `  + =   >  8  = >
 x ~   B  =   =  = = > ~
 B +   =  D+  ~ 8  = >x
x   x  x x      x  xx  x
x   x    x+   xx   x + +  +    +    +
x    x xx     xx                +++   +
x+  +x +x     x + +      +  +
 8=+,  _         +    +   +         +
   +     +                +  +    +
 +             +  +  +      + + +    +
   +    +      +           +
   +    +      +          +    +      +
   +           +            +
   +      +  + +            +
   +       +   +            +
          +    +            +
# +   +                  +
#+     +     ++  +     +     +
#  +      +     +
+#
  *   +
  *+*

   *************************************************+
# +  +
#          +                                       +
   +    + *
         *****+
# +       +
#   +        +
  * *
   +*****
#        +
   ( printout t 164         )
(exit  )  
#cepp  
MsgBox(0,"",169                     )
#cs  
Yo::=~147
::=  
You can see an x here.<<<<

>{-<<  
>SET x TO 120. [0]{472454523665721469465830106052219449897}
>X x. PPQ-}
>x--/2  
> =157;y=146--/2 
>main=print y{-ss 

\begin{code}  
{-x   ␉␉␉␉ 
␉
 ␉  



-}
open import IO;main = run         (putStr"159"   ) --s
\end{code}
pppppppppppp
Take Northern Line to Tooting Bec
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Embankment
Take Bakerloo Line to Embankment
7 UP
Take Northern Line to Mornington Crescent
7 RIGHT
7 RIGHT
7 TEACH
6 BOND
6 BOND
6 BOND
5 RIGHT
5 LEFT
5 RIGHT
7 BOND
7 TEACH
5 TEACH
6 YELL
5 TEACH
6 YELL
6 YELL
set ! 57,,...,,.,,..,,,,,,..,,,.$^
set ! 51.                         #"6027"1,_ye do{--}gibe16"124"&#8+*sizeString tnd xfmain=9717 96lo
More 91 of this red down one blue up red down one blue up red up one red right two blue up ssswwwWWWwWWWWWwWWWWWWWwWWWWWWWWW baa baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bleeeeeeeeeeeeet bleeeeeeeeeeeeet bleeeeeeeeeet baaaa bleet bleeeeeeeeeet bleeet bleeeeeeeeeet
How much is it*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1""//*
#include<stdio.h>
#define  x(d) #d
#define u8 "38\0 "//"
char*x="24 10 31 1"
"a c #FFC0FF""B c #0000C0""d c #58007B""e c #0C8302"
"h c #E60001""i c #CAFFFF""j c #280000""k c #CA0000""l c #CA007F""n c #330001 ""q c #E60000"
"o c #FF8000""t c #FF00BC""u c #008080"
"A c #0040C0""E c #808000""F c #00C040""G c #008000 ""R c #800000"
"H c #0000AA""I c #00AA00""J c #55FFFF""K c #AAAAAA"
"r c red""g c green""b c blue""c c cyan""m c magenta""y c #FFFF00""x c black""_ c #FFFFFF"
"HHHahtdegggggggyrggggggc"
"IHHaixuEFbGGbggbryAEGRgc"
"JJHajyurbgbgggggggb____o"
"IJHakmyyyyyyyyyyyyyyyyye"
"I__almyyyyyyyyyyyyyyyyye"
"K__anmyyyyyyyyyyyyyy_y_e"
"HH_aqggyyyyyyyyg____m_Je"
"JH_axxxxxxxxxxxxxxxxxxxx"
"K__aaaam___bbbbbBm_bbBab"
"K__________bbbbb___bbxbb";//"
int f(char*a,char*b    ){  puts(a?"124":sizeof(0,u8)-5?u8"67":*u8""?"37": x( 0'0  "'\"")[9]?"75":'??-'&1? "79":"77"  );}main(){f(x,x=0);}//<*/
#1""/*/

>data B=B Integer--WWWWWWWWWWWWWW<<W<p
>instance Eq B where{-[ppWWWWWWWWWWWWay Uce stagehere]-}(B a  )==  (B b)=a==b
>instance Num B where{ fromInteger=B;negate  ( B a             )=B$a+1}
>main=print$last$169+1:[128|B 2==head  [(-1 )::B]]--}


#1""/*/
#if 0
#endif//* --... ...--
/*/
p=sizeof(" (\");   print'(''72'')';end!" );main(){    puts('??-'&1?"101":"92");return 0;}
#if 0
#endif//* rk:start | print: "69" rk:end                   @,-1,:*b5<>␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␌␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␌␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋
print 61
#}
disp 49
#{
}{}<>        K yya+-        &  g+$
$'main'3x             A=AgRA;       AC
#-3o4o#$$$
#<T>"3"O._</+++++++>/+++<-\>+++.---.\_<!+++++++++++++++++++++++++++++++++++++++++++++++++._++.-.>@
#<<<#>>>  /
reg end="";print(85);reg s#++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-.
=end
;"""#"#xxxxclou"78"<\++++>/<~#class P{function:Main (a:String[]  )~Nil{83->Print(); }}
#endcOmment
#nocOmment   outtext("155"   )
#ce pS9^7^8^MUOUOF @0:8:8  \ @,,1'1'<> @125iRE
# |o51~nJ;#:p'34'3         \=#print(   size([[1] [3]][1,:] )[1]==2?158+4:17 )#>say 27#p>>>say 170-3#]#print(47)#]#echo 21#v>++++
#8M`|   <esc>dggi2<esc>//  $}<}}<}>} [<<}<<<<<}<<}<<<<}<<<}}}<}}<}}<}}<    }}<}}<}}}<}}<<<<<<<<<<<}}}<}}<}}<}}<}}<}}<}}}<<<<<<<<<<}+++++++++++++++++++++++++++++++++++++++++++++++++._++.._#]~-<~-<~-<<<~-<COprint("65")#`=>ass^_^_#
#9 "25"   +/ppppppp  ggeeee*n*n*n*es^*s*s*ee*n*n*n*e*sss*e*n*n*n*ee<*s 5>1  *e*///\)Q222999686#

VIP score (Versatile Integer Printer): .001820 (to improve, next entry should be no more than 9100 bytes) Try it online!

Explanation

The new language is the same old Haskell we used before, except with the language extension NegativeLiterals enabled. The negative literals extension is pretty simple it makes it so that when Haskell is desugaring negative literals it applies fromInteger.negate instead of applying negate.fromInteger. Usually this doesn't make a lick of difference to the way a Haskell program behaves, however thanks to this SO answer we can use split the two versions of Haskell.

>data B=B Integer deriving Eq
>instance Num B where{fromInteger=B;negate(B a)=B$a+1}
>main=print$last$170:[128|B 2==((-1)::B)]

This prints 128 normally and 170 when NegativeLiterals is enabled. I replaced the existing code with this.

Grass

This program would have added vw to grass, which is not something we could afford. I was able to remove the v by not deriving Eq

>data B=B Integer
>instance Eq B where(B a)==(B b)=a==b
>instance Num B where{fromInteger=B;negate(B a)=B$a+1}
>main=print$last$170:[128|B 2==((-1)::B)]

however this added another w making the code as read by Grass ww. ww is a bit easier to work with than vw because v is a delimiter and thus is really hard to add to the program. In order to make ww work I had to move all of the remaining Grass into the Haskell program.

>data B=B Integer--WWWWWWWWWWWWWWW
>instance Eq B where(B a)==(B b)=a==b--WWWWWWWWWWWW
>instance Num B where{fromInteger=B;negate(B a)=B$a+1}
>main=print$last$170:[128|B 2==((-1)::B)]

There were only two remaining ws so we are all out now, if more are needed some creativity is going to be required.

Balancing act

The insertion of this code caused a few languages to have unbalanced parentheses. In particular the Brain-Flak family are upset by the >s used to make the Haskell literate and the ss upset alphuck. Fixing this one was pretty simple we just add the relevant open parens

>data B=B Integer--WWWWWWWWWWWWWWW<<<ppp
>instance Eq B where(B a)==(B b)=a==b--WWWWWWWWWWWW
>instance Num B where{fromInteger=B;negate(B a)=B$a+1}
>main=print$last$170:[128|B 2==((-1)::B)]

Prelude

Prelude of course had a problem with me adding parentheses to the code. In order to fix this I first tried to minimize the parentheses I used. All in all I was only able to remove one pair of parentheses by changing (...) to last[...] this made the code

>data B=B Integer--WWWWWWWWWWWWWWW<<<ppp
>instance Eq B where(B a)==(B b)=a==b--WWWWWWWWWWWW
>instance Num B where{fromInteger=B;negate(B a)=B$a+1}
>main=print$last$170:[128|B 2==last[(-1)::B]]

From here I just started adding the relevant whitespace.

>data B=B Integer--WWWWWWWWWWWWWWW<<<ppp
>instance Eq B where                                    (B a  )==  (B b)=a==b--WWWWWWWWWWWW
>instance Num B where{fromInteger=B;negate   ( B a             )=B$a+1}
>main=print$last$169+1:[128|B 2==head  [(-1 )::B]]--}

Now since this just needs to be spacing I was able to move parts of the comments into this space to reduce the size of the code

>data B=B Integer--WWWWWWWWWWWWWWW<<<p
>instance Eq B where{-ppWWWWWWWWWWWW-}                  (B a  )==  (B b)=a==b
>instance Num B where{fromInteger=B;negate   ( B a             )=B$a+1}
>main=print$last$169+1:[128|B 2==head  [(-1 )::B]]--}

Incident Incidents

I had quite the struggle with Incident in this case, but I was able to get everything in order, in the end my code came out like:

>data B=B Integer--WWWWWWWWWWWWWW<<W<p
>instance Eq B where{-[ppWWWWWWWWWWWWay Uce stagehere]-}(B a  )==  (B b)=a==b
>instance Num B where{ fromInteger=B;negate  ( B a             )=B$a+1}
>main=print$last$169+1:[128|B 2==head  [(-1 )::B]]--}

Wheat Wizard

Posted 2016-12-06T18:59:02.963

Reputation: 33 549

I think something similar to data B=B Int;instance Num B where fromInteger _=B 170;negate _=B 128 and B x= -1;main=print x might shorten this (and make the Eq instance unnecessary.) – Ørjan Johansen – 2018-01-18T03:03:12.197

Might also be able to replace B with the use of lists. – Ørjan Johansen – 2018-01-18T03:41:37.923

@ØrjanJohansen If I were to do this again I would probably do something like data B=B{u::Integer}, which would give me the function u this would reduce the need for parens (shortening the code drastically) and would mean I don't need it to be an instance of Eq. However at this point things are very fragile so I probably won't be changing the way it works unless I'm already making edits to that section of the code. – Wheat Wizard – 2018-01-18T03:45:41.660

10

40. Minimal-2D, 902 bytes

    #  1"16" 3//v\(@#/;"14"\Dv
#/*`3 auaaZ<>16/"<"6/b.q@")(22)S#  ␉␉␉␉ 
#yy␉;36!@
### ␉
#=␉>
#[#yy#yy0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#`<`␉|
print((eval("1\x2f2")and( 9 )or(13 ))-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"*␉
###; console.log  39
""""#//
=begin␉//
#*/
#define␉z  sizeof 'c'-1?"38":"37"
#include<stdio.h>
int main()  /*/
#()`#`\'*/{puts(z);;}/*'``
$'main'␉//
#-3o4o#$$$
<>3N.<>␉//
#xx\"R++++++++++++++++++\"++++++++++++++++++.----.
#x%~~~+␉+~*ttt*.x
#xx++U++++++++++++++++v<L>4n;
=end   #//
"""#"#//
#0]#echo 21#/(\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE)  ap
#_|#o51~nJ\   
#0␛dggi2␛`␉|1|6$//''25  >>>#>27.say# =#print(17)###^_^_7LEintndus({})!<>+]/*///Z/}23!@222999"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!

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required. Minimal-2D is not available on TIO, but a python interpreter is available here.

Current version of the Incident tokenizer for working with Incident.

Explanation

I couldn't find something I knew that would work, so I googled "2D language" and used the first thing that popped up.

Minimal-2D is essentially Brainfuck, except it lacks loops and used UDLR to redirect a pointer around. If the pointer hits an edge of the file, execution terminates. It can probably be golfed down somewhat; if I get a chance before the next answer comes in I'll try to do that.

The D on the first line sends the pointer downwards to the L in <L>, then the rest is dumb, brute force brainfuck to the U and R. The ++ preceding the U is filler to not break Fission, and the final + on line 22 is Hexagony filler.

Things that broke

><> breaks on D, so it's code is now redirected downwards. Since I was already extending line 20, I used that to terminate the string that got started, and moved the >4n; into line 22. I tried to just use ! to skip the D, but Turtled didn't like that.

Fission broke in various places, which led to filler characters throughout this process. The ++ before the U is all that's left of that now, I think. Those could be changed to whatever is necessary for other languages.

Perl 6 didn't like my unmatched >, so I added in a <.

05ab1e went a little crazy over my extra quotation mark, so I quoted most of line 20 to appease it.

Pyth didn't like the D or the quotations, so all of those got escaped (at least I guess that's what happened? I just tossed a \ before all of them and it worked, so I moved on).

Hexagony was broken most of the time. Then at the end it miraculously worked.

Reng was apparently broken a few answers back and was outputting a nonprintable character before the 19. That's been fixed now by putting the Haystack code before the Reng.

Incident, by this point, had picked up two new tokens that shifted the center, v and +<. So I changed my +< to +v<. Problem solved.

Scores from The versatile integer printer

Just for kicks and going off of @Stewie Griffin's comment on the question, here's a snippet that shows how each answer would have scored if it was entered into "The Verstatile Integer Printer". So far, looks like answer 31 was our best score with a .01094, but still not quite good enough to beat the best VIP score of .009185.

// This was stolen/sloppily hacked together from the snippet here: https://codegolf.stackexchange.com/questions/55422/hello-world. Feel free to clean it up if you'd like.
/* Configuration */

var QUESTION_ID = 102370; // Obtain this from the url
// It will be like http://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "http://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=asc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "http://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)[,\(].*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function getScore(langs, bytes) {
  var l = Math.pow(langs,3);
  return bytes/l;
}

function process() {
  var valid = [];
 
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
        score: getScore(match[1].split(".")[0],+match[2]).toFixed(6),
      });
    else console.log(body);
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery('<a>'+lang+'</a>').text();
    
    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link, score: a.score};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    return a.lang_raw.split(".")[0] - b.lang_raw.split(".")[0];
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.score)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#language-list {
  padding: 10px;
  width: 400px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list">
  <h2>Scores from <a href="https://codegolf.stackexchange.com/questions/65641/the-versatile-integer-printer">The Versatile Integer Printer</a></h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

SnoringFrog

Posted 2016-12-06T18:59:02.963

Reputation: 1 529

3Fun note: changing the text after \" to ++]++++[&gt;+++++++++++++&lt;-]&gt;.---&lt;[-]&gt;. will get brainfuck to output 41. Didn't have time to fix the problems that causes, but maybe it's a decent starting point for someone; esp with SMBF. – SnoringFrog – 2017-02-06T22:57:16.763

I think your Tio link's code is different from your submission. Can you update? – Chance – 2017-02-07T04:10:30.287

@SnoringFrog I was under the impression that the only way to produce SMBF code that will have a different result in BF, is to rely on undefined behaviour in BF? Even if you have a BF compiler that allows you to go left without UB, I suspect it'll be rather tricky to get them both to behave... perhaps not impossible though! – Muzer – 2017-02-07T16:47:08.430

@Muzer It'd hinge on the interpreter. Assuming we use TIO, moving left from the start in BF doesn't error out, it's just a no-op. From there it's just getting BF/SMBF to enter/skip different loops than one another. This does it (kept the line structure of the current program but stripped unnecessary characters). Mixing that w/ the other langs is the issue then.

– SnoringFrog – 2017-02-07T21:37:38.347

@Muzer But I'm not seeing any good/easy way to do that. I'd wager the SMBF needs to be significantly altered to have a chance at making this work with everything else. That line 1 period is annoying. – SnoringFrog – 2017-02-07T21:58:59.187

I requested that Minimal-2D be added to Tio. And it is there now. :) – Chance – 2017-02-08T01:01:08.247

10

46. Cubix, 946 bytes

#  5"16" 3//v\(@;# # \D'[af2.q]'# "14"<;n4
#/*`3 gkggZ">[77*,;68* ,@;'1,q)  ␉␉␉␉(22)PSPP( 
#yx␉;36!@
#`<` ␉
#=
#<]+<[.>-]>[
#{#z}# (prin 45 ) (bye)<
###xR+++++[D>+++++++ndL+++<-][PLEASE,2<-#2PLEASE,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2DOGIVE]>+.---.>][
#Rx%>~~~+ +~*ttt*.x
#D>xU/-<+++L)
#R+.----.>]|
#[yxyx0l0v01k1k0l0ix0jx0h0h1(d111x0eeU0bx0b0o1d0b0ee0ee00m1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l11111100(^_))46(8+9+9+9+9+=!)
#|
print((eval("1\x2f2")and(9)or(13))-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"__*
###;console.log 39
""""#//
=begin //
#seemeePaeueewuuweeeeeeeeeeCisajjapppp/*/
#define␉z sizeof'c'-1?"38":"37"
#include<stdio.h>
main(   )/*/
#()`#`\'*/{puts(z);}/*'``
$'main'//
#-3o4o#$$$
<>"3"O.<>//
=end #//
"""#"#//
#>27.say# /7Jn~49c53c'43'p;|
#8␛dggi2␛`␉|1|6$//''25  =#print(17)#zsss!]#echo 21#^_^_*///$/*23!@4O6O@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 (Versatile Integer Printer): .009718 (to improve, next entry should be no more than 1008 bytes; 953 or less beats the top VIP score)

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required. Incident is checked by keeping the tokens balanced as described in previous answers.

Minor golfing:

I cleaned up a few characters here and there. I'd detail what, but that was several days ago and in the interim I've had to pull two all-nighters, so I barely remember. I do know that I managed to get rid of one of alphuck's ps loops in the first half, so the alphuck/evil line now begins with a single s. Overall, I golfed down to 939 bytes (and I've saved my TIO link for the golfed version of #45 if someone wants to see it).

Cubix:

@Chance has mentioned this language a lot, and after discovering that Octave wasn't going to cooperate and not having any other ideas, I decided to go ahead and add this. I wanted to use pretty much anything else, as this is going to be a beast to maintain, but I was out of ideas. (I did notice that we have a 46 in the code already though. Not sure if there's a way to leverage that. If someone thinks of one, I'm more than happy to delete this answer and use Cubix later).

Cubix/Hexagony interplay is going to be a mess, so I'm hoping that the way I intertwined them doesn't make that any worse.

For following Cubix, you'll want this interpreter. The Cubix code itself is fairly simple, the pointer wanders around the code until it hits the / in the middle of the Hexagony capsule. Fortunately, Hexagony's output command ! is a skip instruction in Cubix, so we avoid the terminating @ and enter the reals Cubix code 4O6O@, which just pushes the digits we need, outputs them, and exits.

Hexagony:

We're back to the left-to-right capsule, which automatically saves us two characters, with an added $/. The / is the mirror Cubix needs (> would also work here for Cubix, but Perl and Hexagony wouldn't like it) and the $ lets Hexagony jump over it. One of the filler z's is now gone as well.

Incident:

Cubix's output detokenized O. I remedied this by capitalizing one of alphuck's c's in the evil line. Evil ignores capital letters, but c was performing a useless action for us. This created a token with two C's from Incident (conveniently almost exactly where the now detokenized O's are) to rebalance things.

SNUSP scare:

In trying to have Cubix dodge a minefield of o and >+<, I rearranged various characters in the SNUSP line (though I didn't know that's what I was editing at the time). I checked the driver for each change and nothing ever complained (which was worrisome, but I just ran with it). As I was typing this up, I checked Modular SNUSP and it failed ("so that's what that line's for!"). Thankfully, other edits meant I could restore the line to what it was before without breaking anything. Close call.

Tips for the future:

We still have a filler z on the last line. Also, the #z on line 7 (PicoLisp line) can be exchanged for a single letter Japt command (I used Q for a bit). You can't remove both though, or z will become a token. But, two of the z's in C/C++ can be changed to any other character. All of these things combined could be useful for generating tokens and for letting you slip in just a few characters without Hexagony and Cubix blowing up.

SnoringFrog

Posted 2016-12-06T18:59:02.963

Reputation: 1 529

1

May I recommend using Glypho at some point. It might be nice because it is mostly character agnostic.

– Wheat Wizard – 2017-03-10T03:09:12.373

@WheatWizard Thanks for the suggestion! We're definitely starting to run low on ideas. Glypho looks workable as long as the aaba instruction doesn't error on an empty stack since this also happens to be Trigger's character agnostic jump code in line 2. If it does error, working an instruction into line one will be a difficult. Maybe a ~5 language solve just for that instruction. Not necessarily impossible though. – Chance – 2017-03-10T14:51:50.863

Awesome :-) Any idea what's wrong with Japt? – ETHproductions – 2017-03-10T18:22:42.460

@ETHproductions I have no idea. It came up in Chance's last answer, not sure if they have a better idea of what's going on. – SnoringFrog – 2017-03-10T20:20:49.833

Emoji might be a good candidate; it ignores everything that's not an emoji. – Robert Fraser – 2017-03-11T03:21:14.137

1@RobertFraser But Python'll blow up because it'll only recognise ASCII characters, unless specified with another encoding, which will cause more problems down the line. – Qwerp-Derp – 2017-03-11T04:50:14.000

@ETHproductions I've gotten as far as figuring out that Japt bombs out on line 607 of the japt-interpreter file with the error "Cannot read property 'm' of undefined". Something about a Japt.flag.m. Sincerely both Cubix and Japt are node.js programs, and cubix works, as well as Japt as a stand run, I think it's likely a switch that needs to be set when running Japt in the driver. – Chance – 2017-03-11T15:32:16.147

@Chance I believe the problem happens because Japt isn't getting any input, which breaks the internal input/flag parser. Hopefully this bug will be fixed when Dennis updates Japt on TIO. – ETHproductions – 2017-03-11T15:41:21.247

@ETHproductions So the stand alone Japt doesn't have anything in Tio's input field either. You think it's maybe seeing an empty string? – Chance – 2017-03-11T15:56:49.877

@Chance I think the way japt-wrapper.js is set up causes it to expect code and input, and because we're not giving it input, it's using undefined instead. It's been updated on TIO now, so I'll check if it's working – ETHproductions – 2017-03-11T16:27:21.843

Hmm, doesn't seem to be working. Is it giving the same error? (I'm not sure how to debug it through TIO) – ETHproductions – 2017-03-11T16:29:00.833

1It works now \o/ – ETHproductions – 2017-03-11T16:52:26.630

10

60. Moorhens 2.0, 1423 bytes

#16  "(}23!@)(" 3//*v\D;'[af2.qc]PkPPX'#)"14";n4
#/*0|7//`"`   ['][!(>77*,;68*,@;'1,@1␉0␉␉11)(22)S␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++  L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.-- -. >][4O6O@
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k10vx0v0l111111^_00)
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.|
#
[ "]56p26q[puts 59][exit]" ,'\[' ];#//
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>)\{(<{}(( {}){})>)}{}({}()) li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"|/=1/24=x'/
__DATA__=1#"'x"//
#.;R"12"'
###;console.log +39
""""#//
=begin //
#sseeeemPaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#*/{puts(p);}/* 
#
/*
<>{//
#}
disp 49#//
#{
}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax
#sss8␛dggi2␛`|$//''25  16*///~-<~-<~-<<<~-^_^_X2229996

Try it Online

VIP score (Versatile Integer Printer): .006587 (to improve, next entry should be no more than 1495 bytes)

Rundown

This program prints 60 in Moorhens 2.0 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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.

  • Modular SNUSP can be tested to output 31 here.

  • This has been tested to working Incident by ais523 on the official interpreter

  • Deadfish~ was tested to output 48 on my own computer, locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are n unavoidable consequence of running any Deadfish~ program.

  • Moorhens 2.0 was tested to output 60 on my own computer using this interpreter.

Moorhens

Moorhens is a bit of strange language I designed a while back. It splits the program up into tokens. Each token consists of an english word surrounded by whitespace. Each token performs one of 11 actions based on its MD5 hash. This TIO program will tell you what command a word evaluates to if you need a quick check (although it won't tell you if that word's actually in Moorhen's dictionary).

Naturally Moorhens found very few tokens in the code to begin with. A troublesome or token was in the python code, but it was removed by deleting the space before it. Other than that Moorhens plays pretty nice with other languages. The current Moorhens code contains 30 xis each incrementing the counter and an ax to play the program in reverse. I had to add a little bit of new code over near the Brain-Flak to prevent it from executing the other tokens hanging around in the code.

Wheat Wizard

Posted 2016-12-06T18:59:02.963

Reputation: 33 549

2I can confirm this works in Incident. (You didn't specify how you'd tested that.) – None – 2017-05-03T20:51:54.063

10

62. Grass, 1616 bytes

#16  "(}23!@)(" 3//*v\D;'[af2.qc]PkPPX'#)"14";n4
#/*0|7//`"`   ['][!(>77*,;68*,@;'1,@1␉0␉␉11)(22)S␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++  L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.-- -. >][
#x%+>+=ttt Z_*.x4O6O@
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k10vx0v0l111111^_00)
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.|
#
[ "]56p26q[puts 59][exit]" ,'\[' ];#//
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>)\{(<{}(( {}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"|/=1/24=x'/
__DATA__=1#"'x"//
#.;R"12"'
###;console.log +39
""""#//
=begin //
#sseeeemPaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#*/{puts(p);}/* 
#
/*
1=61 //
printInt 1//
<>{//
#}
disp 49#//
#{
}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.s
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm
#sss8␛dggi2␛`|$//''25  16*///~-<~-<~-<<<~-^_^_X2229996

Try it online

VIP score (Versatile Integer Printer): .006780 (to improve, next entry should be no more than 1695 bytes)

Rundown

This program prints 62 in Grass 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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.

  • Modular SNUSP can be tested to output 31 here.

  • Amazingly the incident tokenizer in the test driver indicated that the tokens had not changed from the last entry, so I did not bother to run this.

  • Deadfish~ was can be tested to output 48 locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are n unavoidable consequence of running any Deadfish~ program.

  • Moorhens 2.0 can be tested to output 60 using this interpreter.

Explanation

Here is the Grass code:

wWWWwWWWWwv
wWWwWWWwv
w WWWw WWWWWWWWw WWWWw WWWWWWWw WWWWWWWWwwww v
wWWWwWWWWwv
wWWwWWWwv
wWWwWWWwv
wWWwWWWwv
wWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwv

Try it online!

It was taken from an earlier answer made by myself and 1000000000.

Evil

The first problem with inserting the grass was that evil already had some ws in its code which would mess with the grass. In order to fix this I split the grass code into two sections straddling the evil code. Now evil had a little bit of a problem with the grass code. Each w in the grass code printed a null character \x00 so I needed to skip over all the ws, this was done easily with a f and an m.

Cubix

Cubix once again broke because of the increase in program size so I had to move the capsule. Moving the Capsule broke cardinal, but I was able to fix it by adding an x before the Cubix.

Wheat Wizard

Posted 2016-12-06T18:59:02.963

Reputation: 33 549

SILOS has recently had changes, therefore, this was valid with a recent commit, but with the new version, l=61 // doesn't quite work, instead please change it to l+61 – Rohan Jhunjhunwala – 2017-05-18T21:57:47.933

10

63. Brian & Chuck, 1604 bytes

#16  "(}+?23!@)-("//*\Dv;'[af2.qc]PkPPX'#)"14";n4
#/*0|7//```"`   ␉['][!(>77*,;68*,@;'1,@10␉11)(22)S␉␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#_>++++.>.}+?
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++59L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.---.>][
#x%+>+=ttt Z_*.4O6O@
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_00)
[ "]56p26q[puts 59][exit]" ,'\[' ];#/s\\/;print"24";exit}}__DATA__/
#
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.

#
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>){(<{}(({}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( ){puts(p);}/*
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<q>"3"O.s
=end
"""#"
#}
#s|o51~nJ;#:p'34'3\=#print (17)#>27.say#]#print(47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm
# sss8␛dggi2␛`|$// ''25  16*///~-<~-<~-<<<~-^_^_X2229996

VIP score (Versatile Integer Printer): .006414 (to improve, next entry should be no more than 1681 bytes)

Try it online

Rundown

This program prints 63 in Brian & Chuck, 62 in Grass 61 in S.I.L.O.S, 60 in Moorhens 2.0, 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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.

  • Modular SNUSP can be tested to output 31 here.

  • Incident was verified to test 33 via manual balancing of tokens.

  • Deadfish~ was can be tested to output 48 locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are n unavoidable consequence of running any Deadfish~ program.

  • Moorhens 2.0 can be tested to output 60 using this interpreter.

Brian & Chuck

Brian and Chuck are two mutually modifying, BrainF**k-like languages. Like SMBF the memory tape starts containing the polyglot. Brian’s memory pointer is Chuck’s Instruction pointer and vise versa. The polyglot is split with a triple backtick, such that the part of the polyglot prior to ``` is put on Brian’s memory tape, while Chuck gets the portion after.

Backtick is used as a string declaration for Pyth which is used to hide most of the polyglot from its parser. The first instance of such a backtick string is on line 2, and we’ve added a an empty string just prior to this to create Brian & Chuck’s delimiter here: #/*0|7//```"

The +-<> commands for both Brian & Chuck function as you’d expect based on BrainF**k. The , and . commands also function as you’d expect with the caveat that only Brian uses , and only Chuck uses ..

For the more unique commands, we have the ?, which is a no-op if the current memory cell is zero, otherwise it switches control between Brian and Chuck. Also, curly braces will repeatedly move the tape head to the right (}) or left ({) until the cell under the memory pointer is zero/null. And finally, all instances of _ are replaced with null bytes, which makes for a convenient landing space when using curly braces to advance the memory tape.

The program starts by reading line 1 with Brian. The first operation encountered is } in the Hexagony capsule, and it’s here where we begin making changes. The } advances Chuck’s pointer to the _ I added to line 6. I chose line 6 because, as an even numbered line, it’s subject to Retina’s friendlier parser, which is needed for consecutive +’s. Second, this line leaves a buffer line between itself and Labyrinth’s code on line 4, which is needed to maintain the labyrinth walls. And third, we don’t need any spaces, and this is the final line of Whitespace’s command to end the program. This line is also located just prior to the SMBF/BF/Minimal-2D code space, and it aesthetically pleases me to keep the BrainF**k derivatives together.

With Chuck pointing at the _, Brian advances its IP to + which I’ve inserted in the Hexagony Capsule along with a ?. The + gives the null valued _ a positive value which is needed the ? to transfer control to Chuck where we read the bulk of this answer.

So when we switch control, Chuck is pointing at the _ in #_>++++.>.}+?. Chuck then advances it’s IP to the > which moves Brian’s pointer to the 2 in line 1. From here, we increment the 2 up to 6 with ++++, and then output the 6 with .. Then we advance Brian’s pointer again with > landing on the 3 in line 1, which we output with .. Finally, we advance Brian’s pointer to the end of its code segment with }, increment the null memory position with +, and transfer control back to Brian with ?. And from here, we let Brian advance to the end of his tape, ending the program.

It’s super easy to get lose track of who has control and where the pointers are at, so I want to share this configuration which runs Brian & Chuck with a switch for stepping through the code for debugging purposes. I’m sharing the verbose version of this debug switch which also has a @ command that only applies in debug and will terminate the program. The current solution skips over the @ in line 1, so it’s not an issue, but it is something to be aware of if this gets reworked in the future.

S.I.L.O.S.

@RohanJhunjhunwala updated Tio’s S.I.L.O.S. interpreter such that 1=61 // threw an error, which invalidated our test case in the Test Driver. C'est la vie.

This left me with a quandary - do I update the code or the test? @RohanJhunjhunwala rightly pointed out that the = could be replaced with a + to address the issue, so changing the code sounded like the ideal solution, assuming it was compatible with an old enough version of the interpreter. But I ended up taking a different path that came about while I was working on adding a different language: J.

Today, I’ve kind of given up on J at this point. I think it might be possible to add if I’m willing to heavily rework the top 2 lines (and to be honest, I’m increasingly disinclined to do so). But at the time, I had come to the conclusion that J had a blocking issue with Thutu’s requirement of having a trailing // on each line that didn’t start with a #.

I posted to the Polyglot Development board to see if anyone had an idea to get around Thutu’s requirement and @ais523 suggested injecting Perl in Thutu’s parser so it could get past the regex syntax requirement.

Cool!

I later realized that this Thutu hack would allow S.I.L.O.S. to use a more conventional solution, which would allow the S.I.L.O.S. test to remain valid, and golf down both the S.I.L.O.S. and Thutu code. So I jumped in with both feet and gave Thutu its Perl injection and changed the S.I.L.O.S. code to print 61.

Thutu

The Thutu hack is based on the \ command. Here's the documentation's definition:

(When the next character is punctuation) Remove any special meaning the next character might have, even if it's a slash or backslash. Removing the special meaning of a slash prevents it delimiting the end of a regexp, making it possible to write slashes within a regexp.

And this is the code snipped that @ais523 suggested (after I golfed it down and added the necessary bits to include it in the polyglot):

/s\\/;print"24";exit}}__DATA__/

So how does the injection work? Well, a quick look at the interpreter showed this line of code:

@regexps = split /(?<!\\)\//, $_, -1; # Split on / not preceded by \

Now, I’m not the Perl-y-est guy around, but fortunately the comments tell the story. This bit (\\/) from the Thutu line of the polyglot is being parsed by Thutu’s intrepeter as escaping out both the second \ and the /, where traditionally, we’d expect only the second \ to be escaped out.

And because we’ve formatted the line to otherwise look like a valid regex, we get past the syntax checks and arrive at this piece of the interpreter where I believe our Perl injection (;print"24";exit}}__DATA__) gets executed:

foreach $regexp (@regexps)
{
$regexp and print "/$regexp/ $regsep "; # Guards are just Perl regexps.
}

Originally, this was intended to just allow Thutu to bypass its regex syntactical requirements on a line, but what actually happened is it little broader. Every line after the injection point stopped requiring any regex syntax. Why is that? Well, we kinda crashed the compiler. But it still produced a good result.

This raised a philosophical dilemma though, did the program run without error? It wasn’t entirely clear. so @ais523 created a metapost to answer this question. The answer came back with an unequivocal yes – the program ran without error.

Cool. So now, Thutu runs through this line:

[ "]56p26q[puts 59][exit]" ,'\[' ];#/s\\/;print"24";exit}}__DATA__/

And everything past this compiler crash point doesn’t need to conform to Thutu syntax. This means that the space between =begin and =end now has virtually no syntax requirement as long as you don’t cut in the middle of any existing code pieces.

Where to go from here

Ok, there is one syntax requirement between the =begin and =end . Any code pieces that use Brain-flak tokens (){}[]<> without being preceded by a # will be exposed to Brain-Flak. But there is almost certainly a way to work around this one. So where are the safe spaced to add code in here?

There are a few:

• Before or after print 61

• Before =end

• After =begin

• After <>{

• After }<>

@Luke mentioned in polyglot chat he thought he had an answer to go next, and I'd point to these locations as probably good locations.

Good Luck.

Incident Report

#<R>"3"O.s became #<q>"3"O.s because Ris no longer a token and this detokenizes q

$'main' became $'main'3 In order to detokenizes ' ␊ and '3

###;console.log +39 became ###;console.log 39 Because 3 was no longer a token.

sseeeemPaeueewuuweeeeeeeeeeCisajjap became sseeeemPaeueewuuweeeeeeeeeeCis:ajjap Which detokenizes : and sa

]>+.-- -. >] became ]>+.---.>] because --. and .> are no longer tokens.

1k10v became 1k1x0vto detokenize 10

A Couple things I forgot to mention

I golfed off the 3 at the end of the C/C++ processor directive on line 1. This was to counter the addition of characters to line 1 so I didn't have to totally rework all the 2D languages. Just most of them.

Also, I added a - between the ) and ( on line 1 because I added a + earlier that incremented a memory cell in BF and SMBF which I needed to decrement back to zero.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

10

86. Miniflak, 2440 bytes

#16  "}(o+?23!@- "/*\Dv;'[af2.q]PkPPX)\('#CO"14";*/
#/*0|7//```"`  )[-'][(>77*;,68*,@,1',;# l1011)(22)\4nS ␉;␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`
#~
#_>++++.>++++++::@---x---.+?
#`<`
#<<<#>>]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++qL+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.ar4O6O@
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<
'(wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw((.*.*.*.*.*.*.*.*.*.*819.+.*.+@[5]{}) ) )␉\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<\>@*99[?]*]*.*|!)'#
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
' (<><       (          )> ){ ({}[()] )}{\';       a=$(printf \\x00    );b=${#a};

" }"';           (( ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))
=begin
utpb now 70 dollar off!
utpb has been selling out worldwide!
#seeeemPaeueewuuweeeeeeeeeeCis:ajjappp*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1"" //*
#include<stdio.h> 
#define ␉l(d)␉#d
#define u8 "38\0\0"
main ( ␉){puts( sizeof (0,u8)-5?u8"67":*u8""?"37":l( 0'0  "'\"")[9]?"75\0":'??-'&1? "79":"77\0");}//*/
#if 0
#endif//* --... ...--
/*/
print'("72")';end;
#if 0␌
#endif//* rk:start | print: "69" rk:end<>5b*:,1-,@
print 61
#}
disp 49;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>>
reg end="";print(85);reg s
=end
;"""#"#yxxxxxxxxxxx\++++>/<~#class P{   function:Main(a:String[] )~Nil{83->Print();} }
#}
#s|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47) #]#echo 21#fwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8␛dggi2␛M`|$//''   16~-<~-<~-<<<~-COprint("65")#sss^_^_#
#5 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .003836 (to improve, next entry should be no more than 2526 bytes)

Rundown

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl 86 in Miniflak

Verification

Try it Online!

Languages currently not on TIO:

  • Japt, 7 online.

  • Reng, 19 online.

  • Deadfish~, 48 local.

  • Moorhens, 60 local. use moorhens.py from the v2.0-dev branch

  • Morse, 73 local

  • Archway, 74 local

  • Trefunge-98, 76 local. Use -v 98 -d 3 for Trefunge-98.

  • Objeck, 83 local

  • zkl, 85 local

Explanation

Miniflak is a Brain-Flak derivative, where [],<>, and <...> are ignored.

Here was the Brain-Flak code before I started

[][][][]
((([]{})))((()<<()>>)()<<()>>){}{}{}{}({}<(((((()()())){}{})){}{})>)(({})){}{(<(<()>)({})({}<{}>({}){})>)}({}){}({}())
<>{(){
}(((({[]}{}))))
(){(()()[])}
()
}<>
()

Here's what Miniflak sees

((({})))((()())()()){}{}{}{}({}(((((()()())){}{})){}{}))(({})){}{((())({})({}{}({}){}))}({}){}({}())
{(){
}(((({}{}))))
(){(()())}
()
}
()

Miniflak's first problem here is that it can't escape the loop that Classic and Flueue s live in. This is because those two languages use <...> to push the zero used to exit. Since, Miniflak can't see that it never pushes a zero and thus never exits. Miniflak's equivalent operation would be (...)[{}], however [...] prints in Classic so it is to be avoided. Instead we add on {({}[()])}. Since Both of the existing languages have already pushed a zero only Miniflak enters this loop which will decrement until zero. Once Miniflak leaves this loop it will act just like flueue and produce an 82. In order to differentiate the two we add a <()()()()>. Since every other has <...> this does nothing for most the languages, However Miniflak sees this as ()()()() or +4 bringing us up to 86.

The last problem is the block comment. Previously <>{...}<> had been sufficient as a block comment for the flaks, however Miniflak doesn't see <> so it has to be modified to accommodate. The shortest block comment I could come up with that works in all of the languages is

(<><()>){({}[()])}{...}{}<>

So I swapped out the old one for the new one.

Prelude

Prelude took issue with all of the new parens I added to the block comment section. I had to add a lot of new spaces to satisfy prelude.

Other than that all the languages were fine with the addition.

Wheat Wizard

Posted 2016-12-06T18:59:02.963

Reputation: 33 549

10

88. PingPong, 2539 bytes

#16  "?63(o?23!*# #@"/*\DZZCv;'[af2.q]PkPPX)\('#CO"14"; */
#/*0|7//```"`  [>.>.])[-'][(>77*;,68*,@,1',;# l1011)(22)S\4n;␉␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`  e++++++::@ 
#~
#
#`<`
#<<<#>>]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++q   L+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.arxxxxx4O6O@
#D>xU/-<+++L
#R+.----\   \).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO   /"78"oo@0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<
'(wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw  (([5]{}) ) )␉\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<*.*\>]xxxxxxxxxxxxxxxx)'#
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39;'(*****************819+*+@[*99[?]*]***|!)';
""""
' (<><         (          )>  ){ ({}[()] )}{\';       a=$(printf \\x00    );b=${#a};

" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))
=begin
utpb now 70 dollar off!
utpb has been selling out worldwide!
#seeeemPaeueewuuweeeeeeeeeeCis:ajjappp*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1"" //*
#include<stdio.h> 
#define ␉x(d)␉#d
#define u8 "38\0\0"
main ( ␉){puts( sizeof (0,u8)-5?u8"67":*u8""?"37":     x( 0'0  "'\"")[9]?"75\0":'??-'&1? "79":"77\0");"eg_0 ' ";}//*/
#if 0
#endif//* --... ...--
/*/
print'("72")';end;
#if 0␌
#endif//* rk:start | print: "69" rk:end<      >5b*:,1-,@
print 61
#}
disp 49;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>>
reg end="";print(85);reg s
=end
;"""#"#yxxxxxxx"78"\++++>/<~#class P{        function:Main(a:String[] )~Nil{83->Print();} }
#}              @:8:8\\
#s|o51~nJ;#:p'34'3   \=#print(17)#>27.say#]# print(47) #]#echo 21#fwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8␛dggi2␛M`|$//''  1$6~-<~-<~-<<<~-COprint ("65")#sss^_^_#
#5 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .003725 (to improve, next entry should be no more than 2626 bytes)

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl, 86 in Miniflak, 87 in Alice, 88 in PingPong

Verification

Try it Online!

Languages currently not on TIO:

Explanation

Wow, it took 2 full days for me to produce this answer. This challenge can be really challenging.

Adding PingPong

PingPong is another 2D language. It follows the path of haystack - deflects from / on the first line and continues to execute from the last line on the same column. To separate pingpong from other 2d languages I use $ to skip over \. PingPong code is @:8:8\. Second \ is there for retina.

There were two obstacles to adding pingpong on the first line: 1) } terminates current thread (and hence the program as we have only one thread) in pingpong and 2) @ terminates the program.

} was there for brian & chuck. Solved by refactoring brian & chuck.

@ is there for hexagony. Solved by jumping over it with #. To prevent # from changing current ip (0) in hexagony I used *. Second # is there for Algol.

Note that pingpong interpreter returns nonzero exit code, but this is not an error - it just takes the value from the top of the stack (the situation is similar to snusp).

Brian & Chuck

Old brian & chuck was on line 6, mixed with surface. After removing that code I moved surface to line 4. New brian & chuck code:

?63
x>.>.

Brian immediately gives control to Chuck with ?, Chuck then prints 63. [] are there to hide b&c code from bf/smbf. Note that ``` on the second line is not needed for b&c, but removing it breaks pip, which I cannot fix easily, so it stays for now.

><>

Behavior of fish interpreter is ambiguous: when it encounters invalid command it prints error and terminates the program, but returns exit code 0. I am more inclined to treat it as an erroneous termination. So I refactored fish code to terminate cleanly. It was previously intertwined with underload and whitespace. (fish is \4n;, underload is (22)S)

2D languages

2D langs realigned as usual. ZZC on the first line is a filler to align v (tried several letters to satisfy trigger/japt/05AB1E/pyth).
Klein 201 and Klein 100 are moved to line 22 (parens are for underload, quotes are for coffeescript). Klein 001 stays on line 19, but needs right padding.

Incident

Incident gave me a lot of trouble, so here are some tips on fixing incident (see also answer 33):

x1   ...      x1x1 incident code x2      ...      x2x2
                          | 0mo must be in the middle (even_count/2 or (odd_count+1)/2)

some tokens in incident code may accidentally detokenize, incilite to the rescue

Currently:

1:?2 ...skipped... 11:?2 12:?2    13:0l 14:0v ... 41:0mo ... 53:0v 54:0l    55:^_ ...skipped... 80:^_ 81:^_ 
                                  |           incident code            |
                                       note: (81+1)/2==41==0mo

Other langs are fixed as usual.
I added 91 bytes for the code worth 5 bytes. Sorry about that, too tired to golf.

stasoid

Posted 2016-12-06T18:59:02.963

Reputation: 3 177

10

90. RunR, 2585 bytes

#16  "?63(o?23!*# #@"/*\DZZCv;'[af2.q]PkPPX)\('#CO"14"; */
#/*0|7//```"`  [>.>.])[-'][(>77*;,68*,@,1',;# l1011)(22)S\4n;␉␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`  e++++++::@ 
#~
#y
#`<`
#<<<#>>]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++q   L+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.xxxxxxx4O6O@
#D>xU/-<+++L
#R+.----\   \).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO   /"78"oo@0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0\\
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<!\
'(wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw  (([5]{}) ) )␉\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<*.*\>]xxxxxxxxxxxxx)'# \\
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39;'(*****************819+*+@[*99[?]*]***|!)'
#\\
""""#\
' ( <><        (          )>  ){ ({}[()] )}{\';       a=$(printf \\x00    );b=${#a};#\\
" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))#\
=begin
#p
;set print "-";print 89;exit#ss
utpb now 70 dollar off!
utpb has been selling out worldwide!
#seeeemPaeueewuuweeeeeeeeeeCis:ajjappp*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1"" //*
#include<stdio.h> 
#define ␉x(d)␉#d
#define u8 "38\0 "
main (  ){puts( sizeof (0,u8)-5?u8"67":*u8""?"37":     x( 0'0  "'\"")[9]?"75":'??-'&1? "79":"77");"eg5""6 27";}//*/
#if 0
#endif//* --... ...--
/*/
print'("72")';end;
#if 0␌
#endif//* rk:start | print: "69" rk:end<(     >5b*:,1-,@
print 61
#}
disp 49;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>>
reg end="";print(85);reg s
=end
;"""#"#xxxxxxxy"78"\++++>/<~#class P{        function:Main(a:String[] )~Nil{83->Print();} }
#}pS9^7^8^MUOUOF@:8:8\\
#s|)o51~nJ;#:p'34'3  \=#print(17)#>27.say#]# print(47) #]#echo 21#fwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8␛dggi2␛M`|$//''  1$6~-<~-<~-<<<~-COprint ("65")#sss^_^_#
#5 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .003545 (to improve, next entry should be no more than 2671 bytes)

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl, 86 in Miniflak, 87 in Alice, 88 in PingPong, 89 in gnuplot, 90 in RunR

Verification

Try it Online!

Languages currently not on TIO:

Explanation

Adding RunR

RunR is a 2D language with explicit entrypoint.

Spec clarifications:

  • If there are several S last S is used as entrypoint
  • O treats current number as ascii value and prints it as character (so it is equivalent to printf("%c"), not printf("%d"))
  • arith operators pop value from stack

RunR program: S9^7^8^MUOUOF. S starts program, then we push 9, 7 and 8 to stack. When M (multiplication) is executed we have current number 8 and 8 on top of the stack, so result is 64 as current number. Then we subtract (U) 7 from it and print it with O (64-7 == 57 == '9'). Then subtract 9 and print '0'. F terminates the program.

The program contains S, so I added p before it to fix alphuck.

Underload

To fix Underload, we need to enclose RunR code in parens. But there were no place for parens on line 59, so I placed ( on line 46 and ) on line 60 after #s|.

gnuplot

Added set print "-"; to gnuplot code on line 29. This makes it output to stdout instead of stderr. Fixed alphuck as usual. Updated driver - as it turns out gnuplot is installed on TIO (as a tool, not as a language).

Incident

Added some detokenization at the end of C/C++ code. Prior to that I tried to add it on line 58, but broke Fission.

stasoid

Posted 2016-12-06T18:59:02.963

Reputation: 3 177

10

93. Set, 2720 bytes

#16  "?63(o?23!*# #@"/*\DZZCv;'[af2.q]PkPPX)\('#CO"14"; */
#/*0|7//```"`  [>.>.])[-'][(>77*;,68*,@,1',;# l1011)(22)S\4n;␉␉␉␉(1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????!) (qx
#>␉
# 36!@␉`  e++++++::@ 
#~
#y
#`<`
#<<<#>>]}}+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++q   L+++<-][pPLEASE,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---@.>][
#x%+>+=ttt Z_*.xxxxxxx4O6O@
#D>xU/-<+++L
#R+.----\   \).>]|
#[#[(?2?20l0v01k1kMoOMoOMoOMoOMOO   /"78"oo@0l0ix0jor0h0h1d111x0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_0)0\\
[ "]56p26q[puts 59][exit]" ,'\['];#/s\\/;print"24";exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.<!\
'(wWWWwWWWWwvwWWwWWWwvwWWWw WWWWWWWWwWWWWwWWWWWWWwWWWWWWWWwwwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWw  (([5]{}) ))␉\';';print((eval("1\x2f 2")and 9or 13<< (65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{(x<(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*]*(<*.*\>]xxxxxxxxxxxxx)'# \\
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39;'(*****************819+*+@[*99[?]*]***|!)'
#\\
""""#\
' ( <><        (          )>  ){ ({}[()]  )}{\';      a=$(printf \\x00    );b=${#a};#\\
" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;; *1*)echo 50;;*)echo 58;;esac;exit;# (((('))))#\
=begin
#p
;set print "-";print 89;exit#ss
utpb now 70 dollar off!
utpb has been selling out worldwide!
#seeeemPaeueewuuweeeeeeeeeeCis:ajjappppppp
set ! 57
set ! 51
More 91 of thiset of re
How much is it*/
#if 0
.int 2298589328,898451655,12,178790,1018168591,84934449,12597
#endif//*
#1"" //*
#include<stdio.h> 
#define␉ x(d)␉#d
#define u8 "38\0 "
main ( ) {puts( sizeof (0,u8)-5?u8"67":*u8""?"37":     x( 0'0  "'\"")[9]?"75":'??-'&1? "79":"77");"eg5""6 27";}//*/
#if 0
#endif//* --... ...--
/*/
p=sizeof( "(\"           ); print'(''72'')';end!"           ); main( ){puts("92" );return 0;}
#if 0␌
#endif//* rk:start | print: "69" rk:end<(     >5b*:,1-,@
print 61
#}
disp 49;
#{
}{}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.</+++++++>/+++<-\>+++.---.
#<<<#>>>
reg end="";print(85);reg s
=end
;"""#"#xxxxxxxy"78"\++++>/<~#class P{        function:Main(a:String[] )~Nil{83->Print();} }
#}pS9^7^8^MUOUOF@:8:8\\
#s|)o51~nJ;#:p'34'3  \=#print(17)#>27.say#]# print(47) #]#echo 21#fwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm>++++
#s8␛dggi2␛M`|$//''  1$6~-<~-<~-<<<~-COprint ("65")#sss^_^_#
#5 "25"  +/ *///X222999686#

VIP score (Versatile Integer Printer): .003381 (to improve, next entry should be no more than 2808 bytes)

Rundown

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++03, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11, 68 in Python 1, 69 in rk-lang, 70 in Commercial, 71 in what, 72 in Fortran, 73 in Morse, 74 in Archway, 75 in C++11, 76 in Trefunge-98, 77 in C++14, 78 in dash, 79 in C++17, 80 in Klein 201, 81 in Klein 100, 82 in Brain-Flueue, 83 in Objeck, 84 in Klein 001, 85 in zkl, 86 in Miniflak, 87 in Alice, 88 in PingPong, 89 in gnuplot, 90 in RunR, 91 in Cood, 92 in C89, 93 in Set

Verification

Try it Online!

Languages currently not on TIO:

Explanation

Set is pretty simple. Here is the program

set ! 57
set ! 51

This prints ASCII 57 and 51, which is 93.

I added this inside of the Cood program because that seemed like the most appropriate place.

Alphuck

Since I added two new ss I had to balance them with ps in Alphuck. I added two ps to the end of the evil line and everything was just peachy.

Incident

Incident tokenized set So I added a et to the Cood to break the new token.

Wheat Wizard

Posted 2016-12-06T18:59:02.963

Reputation: 33 549

Great answer, 93 languages! – Noah Cristino – 2017-07-24T20:38:00.083

10

155. Simula (cim), 7000 bytes

#16  "?63(o+?50;+'51;'# #@"/*"r"{\D-v e-'[fa5.q]PkPPX)\( 9 '#CO"14"^ 92*/
#/*0|7//```"`  [>.>.])[-'][(      7 >77*,68*,@'_          7 )(22)S/ \ 5 \7aa*+42@n; 7 999993 1 7 3 1 8 1 1 55 EEEEEδΘΔΔΔΘΔΘλiiipsddpsdoh k zzzzkf kf k zzzzzd kf k zzzzza kf bfz(coding=utf8␉␉␉␉1P''53'S^'????!?!??!??!!!!???!?!??!!?!?!!!!!?!!!!?????!????????????????????! 
#>c#z#111#y#y#y#_#1111xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/112\␉
# 36!@␉`  e++++++::@          /"78"oo@    h#115 o# do           x-----
#comment afTaTaTa TbTbTbRtRtRtVkVk-VkRcRcRcBkBkBkMbMbMbLzLzxxxxxxxxxxxx8=,
#~==++++++++++++++++++++++++++++++ +++++++++++++++++++.._+++++++.
#`<`============================================================   x
#<<<#>>]}}+-[.^+;;+;;+;;+<>;;+;;+;;+;;;;;;+;;+;;.._]+-+<[<<.>>x>-]>[
#{
#x}
#2""/*\*
#=x<R+++++[D>+++++++              L+++<-][PLACET,2<-#2FAC,2SUB#1<-#52FAC,2SUB#2<-#32FACREADOUT,2PLEASEGIVEUPFACs]_>@@+.---@._+>][
#x%+>+=ttt Z_*.                                    _         _              _
#D>xU/-<+++L
#R+.----._>]|
#[#[(+?+?0l0v01k1kMoOMoOMoOMoOMOOx0l0ix0jor0h0h1d111 0eU0y0yx0moO1d0y0e0e00m1d0i0fx0g0n0n114O6O@MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i000x1k1x0vx0v0l111111^_0   )0\\
[ "`e```.1'.0'.6''i]56pq{}26q[puts 59][exit]" ,'_\[999'];#/s\\/;print"24"; exit}}__DATA__/
###x<$+@+-@@@@=>+<@@@=>+<?#d>;?\:-._++._++++._#/<?\>3-++._6+---2._#</++++++++++++++++++++++++++++++++++++++++++++++++._++._++++++.!\
'(wWWWwWWWWwvwWWwWWWwvwWWWwWWWW\WWWWwWWWWwWWWWW/WW\wWWWWWWWWwwwwvwWW/WwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwx                  (([5]{})))\';';print(( eval("1\x2f 2") and 9or 13<< (65)>>65or 68)-(0 and eval("\"ppp\".bytes.class==Array and 4or(\"ar_\"[2]==95 and 5-96 or-93)"))^1<<(65)>>62) or"'x"or' {}{}{}{}{}{}{}({}<(((((()()())){}{})){}{})>)(({})5){}x{( <(<()>)({})({}<{}>({}){})>){({}[()])}}({}){}({}()<()()()>)wWW no no no no no no no no no no no no no no no no no no no no no no no no no no os sp '#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("3'3)))"'a'[[@*3*74[?]*.*]*.*(<\>]xxxxxxxxxxxxxxxxxxx)'# \\
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39; 999;
#\\
""""#\
' ( <><        (         x)>  ){ ({}[( )] )}{\';      a=$(printf \\x00    ) ;b=${#a};#\\
" }"';           ((   ( (';case "{"$ar[1]"}"${b} in *1)echo 54;;*4)echo 78;;*1*) echo 50;;*) echo 58;;esac;exit;#(((('))))#\
=begin
#p            +555!/2+55x%6E2x********>********************828+*+@[*9 9[?]*]*****|!
;set print "-";print 89;exit# ss9 111<e$P+x+x+x+x+x*D*x+x+x+1+x+1E!s
utpb now 70 dollar off!
utpb has been selling out worldwide!
#9999 9 seeeemPaeueewuuweeeeeeeeeeCis:ajjapppppp⠆⠄⡒⡆⡘95➡
▲▲▲²²²²▲¡▼¡▲▲¡→
밠밠따빠빠맣박다맣받다맣희맣희うんたんたんたんたんうんうんうんうんうんたんうんうんうんたんうんたんたんうんたんたんうんたんたんうんたんたんうんたんたんたんたんたんうんうんうんうんたんたんうんたんたんたんうんうんうんたんうんうんたんうんうんたんうんうんたんうんたんうんうんうんたんたんうんたんたんうんたんたんうんたんたんうんたんたんたんうんうん
♈
♈♈ +-------+
♉♈ |$0011 \|
♈♈ |/1000 /|
♈♉ |\ 0011\|
♈|/01 00/|
♉♈ |\ 0011\|
♈|@ 0110/|
♈|       |
♈+-------+---
♉
♉⠀⢃⠛⠋
1  1  ! !
2   !    !
1      !!
1  x*
53  +
1  x*
51  +
1  x*
34  +
15  +                    ?   ?@             !
1   *                   ?@    ?
1   !                     +   *
1                       ?  !  ?
1     !                  ? @ ?
<  <    <<   <  <
< B=  =====  =>8 =
, 8= > B    = =
=  ==  =    = >   8  =
D B    =   D  x   xxx x
` `    =   >  8  = >
 ~ B   =  =   =  = > ~
 B =   D  ~   8 =  > xx
x   x  x x      x  xx  x
x   x    x    xx   x
x    x xx     xx
x    x xx     x
 8=,x  x

7 UP
7 RIGHT
7 RIGHT
7 TEACH
6 BOND
6 BOND
6 BOND
5 RIGHT
5 LEFT
5 RIGHT
7 BOND
7 TEACH
5 TEACH
6 YELL
5 TEACH
6 YELL
6 YELL
Yo::=~147
::=
You can see an x here.<<110[0]{472454523665721469465830106052219449897} 9

>{-<<
>SET x TO 120.
>X x. PPQ-}
>main=print 146{-ss

set ! 57,,...,,.,,..,,,,,,..,,,.$^
set ! 51.                         #"1015""6027""ing-?"ye h m 3 ;p seLz
More 91 of thiset of re9 red down one blue up red down one blue up red up one red right two blue up ssswwwWWWwWWWWWwWWWWWWWwWWWWWWWWW baa baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bleeeeeeeeeeeeet bleeeeeeeeeeeeet bleeeeeeeeeet baaaa bleet bleeeeeeeeeet bleeet bleeeeeeeeeet
How much is it*/
#if 0
.int 2298589328,898451655,12,178790,1018168591 ,84934449, 12597
#endif//*
#1""//*
#include<stdio.h>
#define  x(d) #d
#define u8 "38\0 "//"16
char*x="24 10 31 1"
"a c #FFC0FF""B c #0000C0""d c #58007B""e c #0C8302"
"h c #E60001""i c #CAFFFF""j c #280000""k c #CA0000""l c #CA007F""n c #330001 ""q c #E60000"
"o c #FF8000""t c #FF00BC""u c #008080"
"A c #0040C0""E c #808000""F c #00C040""G c #008000 ""R c #800000"
"H c #0000AA""I c #00AA00""J c #55FFFF""K c #AAAAAA"
"r c red""g c green""b c blue""c c cyan""m c magenta""y c #FFFF00""x c black""_ c #FFFFFF"
"HHHahtdegggggggyrggggggc"
"IHHaixuEFbGGbggbryAEGRgc"
"JJHajyurbgbgggggggb____o"
"IJHakmyyyyyyyyyyyyyyyyye"
"I__almyyyyyyyyyyyyyyyyye"
"K__anmyyyyyyyyyyyyyy_y_e"
"HH_aqggyyyyyyyyg____m_Je"
"JH_axxxxxxxxxxxxxxxxxxxx"
"K__aaaam___bbbbbBm_bbBab"
"K__________bbbbb___bbxbb";//"
int  y(){puts ( sizeof (0,u8)-5?u8"67":*u8""?"37":x( 0'0  "'\"")[9]?"75":'??-'&1? "79":"77" );return 2;}int z=0;int q(int a,int b   ){return b;}main( ){q(z+=1,z)?puts("124"):y();}//<*/
#1""/*/
 
>main=putStr"128"--}
 
#1""/*/
#if 0
#endif//* --... ...--
/*/
p=sizeof("9( 999   99\"  ) ;print'(''72'')';end! ");  main(   ){puts('??-'&1?"101":"92");return(9-9+9 -9);}
#if 0
#endif//* rk:start | print: "69" rk:end 9                 @,-1,:*b5<>␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␌␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␌␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋␋
print 61
#}
disp 49 ;9;
#{
}{}<>        K yya+-        &  g+$
$'main'3x             A=AgRA;       AC
#-3o4o#$$$
#<T>"3"O._</+++++++>/+++<-\>+++.---.\_<!+++++++++++++++++++++++++++++++++++++++++++++++++._++.-.>@
#<<<#>>>  /
reg end="";print(85);reg s#++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-.
=end
;"""#"#xxxxclou"78" \++++>/<~#class P{function:Main (a:String[]  )~Nil{83->Print();}}
#endcOmment
#nocOmment   outtext("155"   )
#}pS9^7^8^MUOUOF@0:8:8     \\     @,,1'1'<>   _@125iRE
# |o51~nJ;#:p'34'3         \=#print(17)#>27.say#]# print(47)#]#echo 21#WWWWWWWWWWWWWWWwWWWWWWWWWWWWwv>++++
#8M`|   <esc>dggi2<esc>//  $}<}}<}>}[<<}< <<<<}<<}<<<<}<<<}}}<}}<}}<}}<    }}<}}<}}}<}}<<<<<<<<<<<}}}<}}<}}<}}<}}<}}<}}}<<<<<<<<<<}+++++++++++++++++++++++++++++++++++++++++++++++++._++.._#]~-<~-<~-<<<~-<COprint("65")#`=>asss^_^_# 
#9 "25"   +/ppppppp neeeeee*n*n*n*es*s*s*^ee*n*n*n*e*sss*e*n*n*n*ee<*s 5>1  *e*///\)Q222999686#

Try it online!

Simula is an object-oriented extension of ALGOL. Simula does not allow most of non-whitespace controls (link). Before this addition polyglot had only one such character - ESC for V. To get rid of it I used V verbose mode in which <esc> can be used instead of literal ESC character.

Cim Simula compiler (installed on tio) has preprocessor. I used #comment and #endcomment to hide the bulk of polyglot and #nocomment to insert Simula code on a line starting with #. Invalid preprocessor directives are ignored.

Line 5:

#comment af ...

Lines 153/154:

#endcOmment
#nocOmment   outtext("155"   )

To fix evil: removed a before f on the first line, added af after #comment. Removing a from the first line breaks Beatnik, so I just swapped a and f. Capital Os are for ADJUST.

Line 157:

#8M`|   <esc>dggi2<esc>//  ...

Separated Retina from V. Two spaces before <esc> are for Pip, third space is to fix Archway. // after <esc> is for V. Two es in <esc>s are compensated by removing two es from Paintfuck. Two ss are compensated in alphuck by removing ss from lines 156/157 (previously 154/155). One of these ss is skipped by Paintfuck, so we still need to add one n to fix it. Two <s are compensated with two }<} in BitChanger.

Removed $, '' and string of {s from line 157. Small refactoring: 2 + 35 for l33t on the first line.

stasoid

Posted 2016-12-06T18:59:02.963

Reputation: 3 177

5That's not just "an object-oriented extension of ALGOL", that's the oldest OO language, period! – Ørjan Johansen – 2017-11-10T03:19:30.350

3#comment af ... well that's a pretty good description of this polyglot – Kamil Drakari – 2017-11-15T21:35:46.963

9

12. Fission (110 bytes)

Just adding yet another 2d lang... Streak of 3 2d-langs in a row, let's keep it moving folks!

#v;2^0;7||"<+0+0+0+<*!2'!1'L;n4
#v0#_q@
#>3N.
#|\w*
#8  ^1b0<
#|
#M`
print(None and 9or 1/2and 1or 5)
#jd5ki2

This prints 1 in Python 3, 2 in Vim, 3 in Minkolang, 4 in <><, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl, 10 in Befunge, 11 in Befunge-98, and 12 in Fission.

Try it online!

Explanation

The only important piece of code is the first line

                These are the important bits
                    >------<
#v;2^0;7||"<+0+0+0+<*!2'!1'L;n4
                           ^
                   we start here by creating an atom moving Left
           (I could not use R for Right since that means Replace in Vim)

                       1'          sets the atom's mass to the ASCII value of '1'
                      !            outputs the atom's mass (as a character) 
                    2'             sets the atom's mass to the ASCII value of '2'
                   !               outputs it
                  *                program terminates

Next...

If Fission is causing trouble, remember, you can move the Fission code anywhere you want, since the start of the program is only identified by the commands that create atoms, and the program ends whenever the atoms are destroyed.

You can also change the atom's start direction to suit your needs, R for Right (but Vim will interpret that as Replace), U for Up, D for Down (or Deletes entire line in Vim, can be useful).

Cows quack

Posted 2016-12-06T18:59:02.963

Reputation: 12 883

This answer doesn't work with the Befunge93 answer, it only produces a 0 not 10. – Teal pelican – 2016-12-07T08:54:01.697

1@Tealpelican Works for me. Did you remember the ESC character between j and d on the last line? See the TIO link. – Zgarb – 2016-12-07T08:59:15.420

1Yeah my bad, for some reason chrome was removing it for me. – Teal pelican – 2016-12-07T09:23:59.420

9

22. Underload (stringie), 173 bytes

#v`16/"<"6/b.q@"(::):: :(22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++ %
#=~nJ<R"12";
#[

print((1/2and 9 or 13)-(0and+4)^1<<65>>62)#46(89999+++++!)=#print(17)#]#echo 21
#8dggi2` |1|6

As before, there's a literal ESC character immediately after each of the 8 and 2 on the last line.

This program prints 22 in Underload, 21 in Nim, 20 in Prelude, 19 in Reng (testable here), 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, 8 in Retina, 7 in Japt, 6 in SMBF, 5 in Python 2, 4 in ><>, 3 in Minkolang, 2 in Vim/V, and 1 in Python 3.

stringie is the Underload interpreter used by Try It Online! Fortunately for polyglotting, it ignores non-command characters rather than crashing on them, so the main thing to ensure is that there are enough stack elements that we don't get an empty stack crash (done here with (::):::; the code probably doesn't actually need that many colons, but I added them anyway as padding to remove awkward vertical alignments). Because it had to appear fairly early (it needs to be before any instances of aS^:*~!), I placed the Underload code on the first line; thanks for Sp3000 for suggesting a place where it would fit safely.

I needed to leave an additional space on the first line because Cardinal doesn't like : lined up with %; I also needed to structure the Underload code to avoid parentheses lining up with each other vertically (which Prelude dislikes). Pyth was the hardest language to get working, and I needed to resort to advice from Sp3000 there (who suggested moving the double quotes around; this combination works). In an earlier version of the code, the Underload was further to the right, but that got in the way of Turtlèd.

The space immediately after the Underload (i.e. after the S of (22)S should still be safe; the Underload doesn't change that. In order to avoid causing problems for Underload, ensure that your code has matched parentheses, avoids S, and isn't intelligible enough as Underload code to cause problems in its own right. (::) has a tendency to breed once it's placed on the stack (I intentionally wanted to write the Underload in a fairly robust way to make continuing the chain easier), so most random sequences of non-S characters will be safe from here, but it's possible to defeat the "ignore the rest of the program" if you try hard enough. If you need an S for some reason, try ensuring that some pair of parentheses captures it; that'll cause Underload to treat it as data rather than code and avoid producing stray output.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

Any hints on where 1 or 2 characters (other than spaces) can be added later in the program? I'm trying to do a hexagony submission, so it's ok if it has to be certain characters, as long as it isn't just white space. The addition of all the :s means that I have to route program flow around them so they don't cause divide by 0s – Mistah Figgins – 2016-12-09T01:32:21.567

@MistahFiggins: How late do you need them? Immediately after print(17)# is a location that every language with block comments, and every 2D language, currently ignores, so as long as you add characters that are safe for the languages which parse everything, you should be OK. Digits should hopefully be a pretty harmless thing to use if you just want some sort of padding and don't care what it is. – None – 2016-12-09T02:18:02.643

This will work, thanks! There are 22 languages now, so it's a little hard to keep track of what's run in which language. – Mistah Figgins – 2016-12-09T02:19:40.617

9

25. Pip, 220 bytes

#v`16/"<"6/b.q@"(::):::  (22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++~~~%
#=~nJ<R"12";
#[
#|
print((eval("1\x2f2")and 9 or 13)-(0and+4)^1<<65>>62)#@46(8+9+9+9+9+=!)=#print(17)#3]#echo 21#===2|/=1/24=x=9+/
#8␛dggi2␛` |1|6//1''19+6

represents a literal ESC character, as per previous submissions.

This program prints 25 in Pip, 24 in Thutu, 23 in Hexagony, 22 in Underload, 21 in Nim, 20 in Prelude, 19 in Reng (test here), 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, 8 in Retina, 7 in Japt, 6 in SMBF, 5 in Python 2, 4 in ><>, 3 in Minkolang, 2 in Vim/V, and 1 in Python 3.

The 1|6 is used by both Retina and Japt and the // serves to comment out the end of the code so that Japt doesn't output anything else. I feel like 26 should be fairly 'easy' to sneak into the end since SMBF needs a trailing 6, so anything that will output the last item in the code (being 26) should be at an advantage... Perhaps 05ab1e? Good luck!

Dom Hastings

Posted 2016-12-06T18:59:02.963

Reputation: 12 968

1I had a look at 05AB1E. It almost works very easily; the main issues are Hexagony (this one's easily solvable), Pip, and Japt. (The problem is that Pip comments start with two spaces, and Japt doesn't like that at all, because a space is the equivalent of a closing parenthesis; this causes Japt to add opening parentheses to the start of the program to balance, leading to a syntax error because the closing parentheses are commented out.) 05AB1E next still seems like a good idea – it'll output 26 for almost any program ending 26 – but maybe you'll have to move the Pip earlier. – None – 2016-12-14T15:35:14.277

Followup: $// works as a comment marker in Japt that's happy to see spaces later on the line. I might have another try in a bit, but if someone else wants to get there first, go for it; testing a program in 26 different languages is exhausting. (Also, it's too late to edit my previous comment, but I should have said "almost any program ending "26".) – None – 2016-12-14T15:44:22.483

@ais523 Agree about tiring testing, such hard work! What's annoying is finding a problem in Japt and having to re-test the others! I did really enjoy this challenge though. I wonder if there's a record for the smallest polyglot with most languages... – Dom Hastings – 2016-12-14T15:45:50.963

The problem is precisely that // is a comment marker in Japt, but Japt doesn't know it's a comment marker, so it tries to balance parentheses in it and ends up making things worse. $// avoids that problem by telling it not to parse the stuff until the next dollar. – None – 2016-12-14T15:46:30.133

9

29. Trigger, 292 bytes

#v`16/"<"6/b.q@"(: ::T): :(22)S#;n4"14"
#>3N6@15o|> ^*ttt*~++~~~%
#=~nJ<R"12";
#[
#`<`|
print((eval("1\x2f2")and (9) or (13))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{\/+23!@=}[()])}\{})(\{}\{})'#@46(8+9+9+9+9+=!)=#print(17)#]#echo 5+5+11#|/=1/24=x=90/
#8␛dggi2␛` |1|6$//''25  #>say 27#T222999"26

This program prints 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 (tested here), 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.

Something must have been working in my subconcious in the time since the last submission to this challenge, because by the point I decided it was running low on time and I wanted to ensure it wouldn't die, I suddenly remembered a language from years back that could be added fairly easily as seen by the low increase in the byte count, and quite a bit of that was due to Hexagony rather than Trigger itself. Except for commands that assign to variables (which mostly don't matter), all Trigger's commands contain two consecutive equal characters. The first time this happens is in the Underload code in the first line, so I simply modified that a bit to jump to almost the end of the program, and placed the Trigger code to print 29 (which is 222999) there. The jump label I used is T (originally I tried U but Fission disliked it), but if you need to use a capital T in your own program for some reason, you can easily change both occurrences to something else that isn't used in your program.

Very little else needed changing, apart from (as always) the Hexagony. I decided it was time to stop messing around with formatting the code into a hexagon by hand, but luckily we've already had a challenge about Hexagony parsing, so I went and modified this answer to the challenge into an online-usable Hexagony formatter that handles backticks correctly (here). Here's how this version of the program looks as a hexagon:

         # v 1 6 / " < " 6 /
        b . q @ " ( : : : U )
       : : ( 2 2 ) S # ; n 4 "
      1 4 " # > 3 N 6 @ 1 5 o |
     > ^ * t t t * ~ + + ~ ~ ~ %
    # = ~ n J < R " 1 2 " ; # [ #
   < | p r i n t ( ( e v a l ( " 1
  \ x 2 f 2 " ) a n d ( 9 ) o r ( 1
 3 ) ) - ( 0 a n d 4 ) ^ ( 1 ) < < (
6 5 ) > > 6 2 ) o r ' ( \ { ( \ { } )
 ( \ { \ / + 2 3 ! @ # } [ ( ) ] ) }
  \ { } ) ( \ { } \ { } ) ' # @ 4 6
   ( 8 + 9 + 9 + 9 + 9 + = ! ) = #
    p r i n t ( 1 7 ) # ] # e c h
     o 5 + 5 + 1 1 # | / = 1 / 2
      4 = x = 9 0 / # 8 ␛ d g g
       i 2 ␛ | 1 | 6 $ / / ' '
        2 5 # > s a y 2 7 # U
         2 2 2 9 9 9 " 2 6 .

You might well have noticed that the Nim code is more verbose than it used to be. This is purely because padding it out as 5+5+11 rather than 21 happened to make the Hexagony line up perfectly; if you start at the / of /+23!@#, you can see an uninterrupted run of Hexagony-safe characters, and that's how I made that part of the program work.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

1+1 for the updated hexagony formatter. Are there any online resources for testing in Trigger? I think it may have blown out my next solution. :P – Chance – 2017-01-05T17:00:47.983

@Chance: Not yet, although I put in a request for it on TIO. Also, I'd be both surprised and upset if Trigger ended up blocking a language, because it's fairly easy to work into a polyglot; it doesn't parse code you jump over, and its jumping ability is fairly flexible. – None – 2017-01-05T17:16:39.183

Yeah, I've been digging into some turing tarpits with limited character sets, which had a lot of repeated characters as you'd expect. I'll read up about Trigger's jumping ability though. Maybe it is workable. – Chance – 2017-01-05T17:40:36.007

@Chance: The : ::U in the current program jumps to the U at the end. Everything in between won't even be parsed, so you can repeat as much as you like there. – None – 2017-01-05T18:31:11.630

/+23!@= != /+23!@# – CalculatorFeline – 2017-03-10T17:16:40.807

9

34. Rail, 549 bytes

#v`16/"<"6/b.q@"(: ::Q):  ␉␉␉␉ :(22)S#;n4"14"
#>3N6@15o|>␉^*ttt*~++~~~%
#= >␉1#v#v0l0mx01k1k0l0ix0jx0h0h1d111x0ex0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#[␉
#`<`|
print((eval("1\x2f2")and(9)or(13 ))-(0and 4)^(1)<<(65)>>62)or'(\{(\{})(\{}[()])}\{}\{}\{}) '#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]]/
__DATA__=1#//
#.\."12"␉;
""""#//
=begin␉//
$'main'//
#-3o4o␉
=end   #//
"""#"#//
#]#echo 21 #//=#print( 17)
#   +/Jn~
#8␛dggi2␛`␉|1|6$//''25  #>say 27#$nd^_^_.Q222999/+23!@"26

As usual, is a literal tab, is a literal ESC character.

Rundown

This program prints 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

Try them online!

For the languages that aren't supported by the above test driver:

  • V can no longer test the full polyglot in Tio because it takes too long to run now. But I have added a test to the above test driver to run all code after ␛dgg in the polyglot since these V commands essentially invalidate all prior code.
  • Reng can be tested here, and outputs 19 as expected.
  • Modular SNUSP can be tested here, and outputs 31 as expected.
  • Incident was confirmed to output 33 by ais523.

Explanation

I too have been planning! I have long been stymied by the limitation of starting every line with a # or exposing the code to Python, Ruby, and Perl. Well no more! I decided to rip a literal hole in the code. (I use the term literal figuratively.) We're now including a literal string from the perspective of the scripting languages, so that we can begin lines with characters other than # which Rail, takes advantage of.

Kill Perl

The first problem was that Perl 5 didn't want to execute when there was an unsigned string, so after some experimentation, I settled on killing Perl 5's execution after the big print statement. This is handled with __DATA__=1. This is followed by # to comment out Thutu's //. You'll see these in the solution wherever there is a line that doesn't start with a #. They seemed to make Thutu happy.

The DATA in this statement created two other consequences as well. First, we were using T as our Trigger jump label, so that got changed to a quirky Q in first line's : ::Q and the last line's Q222999. Second, Fission treats UDL and R as starting points and the D in DATA kicked off another fission reaction heading in the down direction. So, I had to kill the 3rd line's Fission statement R"12"; and create the line #.\."12"␉; to make sure the reactor didn't melt down. The \ redirects Fission's code path along the line and the .'s are just for spacing.

Let's Get Literal

Both Python flavors use """ to denote the beginning and end of literal strings. Ruby naively thinks " denotes a literal string and has no problem with multiple literal strings bumping up against each other and not being used. But Ruby, Perl, and Pip just could not all agree on when the stuff in between the starting and ending lines for the literal string where actually strings. I settled on letting Pip and Python agree and letting Ruby think what's in between is code. So, this line """"#// and this line """#"#// begin and end the string from Python's perspective. Ruby ended up going to a multi-line comment syntax in the middle of all this business with the =begin // and =end #// statements.

Reng Around the Rosie

With all the extra #'s floating around, Reng had all kinds of problems, so it's code got moved to the bottom and I golf'd out the extra x in the Whirl-Incident capsule. At this point, I believe the only 2D lang to traverse the literal string's space is Cardinal and it can be moved into and bound within the literal zone, but I didn't have the byte count to accomplish this today. Next time.

Ride The Rail

Rail starts at the $ in $'main'// and continues heading right on the next line starting with the -in #-3o4o␉. The $'main'// line is pretty flexible for inter mixing other code, so it's a good place to add onto.

The Literal Zone

New lines can be added now above or below the Rail code with a few stipulations:

  • Lines need to be added in pairs for Retina to keep working.
  • Lines not starting with a # are exposed to Thutu but have generally worked for me if I end the statement with //
  • Code before a # is still exposed to Brain-Flak, so (){}[] and <> may cause problems.
  • Every other line should have a literal tab for Whitespace. Or, if this pattern has to be broken, a triple space will usually work.

Incidental Edit

Incident required a few alterations. $ and nd turned out to be new tokens after the refactor, so I added an extra set of both of these tokens near the end so they no longer counted. The Hexagony module needed to be nearer the end than Incident's final jump token wanted to be placed as a copy of the end of the module, so I had replaced the final jump token with ^_ which all appear before hexagony. Finally, I believe a [ got pushed to the other side of the bulk of incident's code Incident's which I believe caused the center token to be changed. AIS523 pointed out that an extra set could probably be added safely around the Modular SNUSP code, which worked out nicely and let us meet the byte count, just barely.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Fails in Incident due to adding a lot of new strings that are repeated three times after the Incident code; the control flow in the Incident program is still correct, but there's no longer an 0o in the centre of the program (the centre of the program in tokens, as seen by Incident, comes rather later). This seems fixable, however. – None – 2017-01-18T01:16:52.777

Dangit, I was going to add Cubix as 34, which would only require a carefully placed QO@... – ETHproductions – 2017-01-18T01:20:14.673

Here's how the code looks in Incident at the moment, to help you fix it. The centre of the program, measured in tokens, is currently the second 0g (all three 0g are underlined in the screenshot). It needs to be an 0o; the one three tokens earlier looks promising, but means you'll need to break up some of the tokens later in your program. – None – 2017-01-18T01:28:39.273

@ais523 Ok, I may not have understood Incident before. I believe if I add the offending tokens a fourth time, they will cease to be valid for Incident. So I have added another copy of $ and nd in a safe spot and changed the final jump token to make Hexagony work. Would you mind verifying again? – Chance – 2017-01-18T03:34:08.873

@ETHproductions Thanks for the Retina catch. Not sure when I busted that in the refactor, but looks good now. I bet you could work in Cubix still btw. ;) – Chance – 2017-01-18T03:35:44.573

1It still doesn't work, due to more stray tokens; the easiest fix I've found is to add an additional [ and ] (each of which currently appears three times). I placed them around the SNUSP code; no idea if that breaks anything else. – None – 2017-01-18T15:50:08.950

1@ais523 Thanks again. That looked like a good fix for everything else. I had to reduce the second Incident jump code to 2 characters to meet the byte limit. We might need something that identifies Incident's tokens and specifically the center token for testing purposes. – Chance – 2017-01-18T17:20:37.397

2I can confirm that this works in Incident now. I agree that an Incident syntax highlighter would be useful here (there's one as part of the Incident distribution, but that's not really usable online). I know Martin Ender was considering starting a challenge about writing one; I wonder what the progress on that is like. – None – 2017-01-18T18:11:07.437

@ais523 I added an test to the Polyglot test driver for handling V. Since V seemingly can no longer execute the full polyglot online I'm attempting to only send the code that appears after ␛dgg which I believe invalidate any prior code in V. It's not an ideal solution, but it is better than nothing I think. – Chance – 2017-01-23T18:20:47.810

9

39. CoffeeScript, 828 bytes

#  1"16" 3//v\(@#/;n4"14"
#/*`3 auaaZ<>16/"<"6/b.q@")(22)S#  ␉␉␉␉ 
#yy␉;36!@
### ␉
#=␉>
#[#yy#yy0l0mx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10mx0m0l11111100(^_)
#`<`␉|
print((eval("1\x2f2")and( 9 )or(13 ))-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"*␉
###; console.log  39
""""#//
=begin␉//
#*/
#define␉z  sizeof 'c'-1?"38":"37"
#include<stdio.h>
int main()  /*/
#()`#`\'*/{puts(z);;}/*'``
$'main'␉//
#-3o4o#$$$
<>3N.<>␉//
#xx
#x%~~~+␉+~*ttt*.x
#xx
=end   #//
"""#"#//
#0]#echo 21#/(\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE)  ap
#_~nJ|#o51\   
#0␛dggi2␛`␉|1|6$//''25  >>>#>27.say# =#print(17)###^_^_7LEintndus({})!<>+]/*///Z/}23!@222999"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 them online!

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required.

Here is yet another evolution of the Incident tokenizer, I reworked it so the polyglot can be put directly to input and removed the linefeed replacing format from the test driver since it was no longer needed.

Edit: Thanks to @SnoringFrog to pointing out how to fit CoffeeScript into the test driver. Link is updated.

Explanation

This answer came directly from this general polyglot tip by @Sp3000 where I learned that Coffeescript used # based comments, and a different block comment indicator than all the other languages we’ve used so far. @Sp3000’s example didn’t have the output going to STDOUT though. So I took a quick trip over to the PPCG Hello, World! Collection and found that @Lynn provided an example here that was closer to my STDOUT tastes. Sweet.

Here are the CoffeeScript syntactic highlights:

  • # This is a line comment
  • ### This is a block ###
  • """ This is a literal string"""
  • console.log 39 # This is the STDOUT print statement

There were only a couple quirks with CoffeeScript that I had to work out. First, the print statement really needed to live behind a # to hide from the other languages, but the statement seemed to want to be on its own line. This was eventually resolved by throwing a ; between the end of the comment block and the print statement.

Second, the block comments seem fail on the C/C++lines. I’m not sure why exactly, but my guess is something to do with the /* comments. (CoffeeScript is used to programmatically generate JavaScript which uses /* comments. /Shrug. ) In any event, I found that I could use Python’s syntactically matching literal string to hide this code more effectively. So I simply dropped out of the block comment earlier than I had planned to print 39 and everything else was just magically hidden from CoffeeScript. Great Success!

The Few Things I Did Break

Retina didn’t like the line I inserted for console.log 39, so I needed to remove a line for Retina’s rule of even numbers. Maybe I just made that rule up, or maybe it’s legit. It feels legit. Anyways, there was already a do nothing line in the Python string. So I just removed that. This changed the value of Retina’s output, but that was easy to fix by throwing a few more 1’s in the long Python print statement. So far so good.

Hexagony’s hex got bumped up to the next size, so I had to resolve that. But first, the new Hexagony module /(3!@) , while super effective, made my Prelude sense tingle. I didn’t like the idea of having to move this all the time for Hexagony’s alignment and then having to redo Prelude’s vertical parenthetic alignment. So I dug in and found a new Hexagony module that didn’t have this poly-linguistic baggage: /}23!@.

Incident, in all these tweaks lost its singular left side incidental token. (Get it? Cuz it’s not used by Incident… Never mind). The easiest solution to re-balance Incident’s center token turned out to be CoffeeScript’s block comment. So, I added the 3rd ### just prior to final pair of jump tokens (^_). This put one unused token on the left side and eight unused tokes on the right side. (Eight minus one is lucky number seven.) This also happened to align the hexagon so the Hexagony module could be nested in Trigger’s code like so: Z/}23!@222999.

Whitespace was the last piece of broken code, but it was not too difficult rebuild. It was just a matter of removing lines from the end until it worked, and then putting them back one by one and figuring out if I should make it a triple space line, a tab line, or a no whitespace line.

Good Luck.

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

Nice one! There are definitely more things that can be done with #-initiated multi-line comments, I think. – Muzer – 2017-02-04T01:23:49.013

@Muzer Thanks. Yeah, I decided go into some # space since you've been having so much success with the C variants. Looking forward to your next. – Chance – 2017-02-04T02:12:39.793

coffee polyglot.poly is all you need to add it to the driver, at least that worked for me – SnoringFrog – 2017-02-06T15:38:02.443

@SnoringFrog And of course it's the easy solution I didn't bother to try. Thanks! – Chance – 2017-02-06T19:42:53.550

1"Retina’s rule of even numbers" → Retina has two parsers, and (in the common case where lines don't contain the backquote character) alternates which one it uses from one line to the next. One is a lot more tolerant than the other one, so making sure that complex lines end up on the tolerant parser is likely going to be helpful. – None – 2017-04-27T23:53:40.907

9

42. evil, 930 bytes

#  4"16" 3//v\(@#/;\D"14"<;n4
#/*`3 afaaZ">;[77*,68*,@;'1,'1,q)(22)S#   ␉␉␉␉ (
#yy␉;36!@
#`<` ␉
#=␉x
#<]+<[.>-]>[
#␉<
###xR+++++[D>+++++++L+++<-][<<<]>+.---.>][
#px%>~~~+␉+~*ttt*.x
#D>xU/-<+++L)
#R+.----.R␉>]|
#[#yy#yy0l0vx01k1k0l0ix0jx0h0h1d111P0eU0bx0b0o1d0b0e0e00x1d0i0fx0g0n0n11x0o0n0cx0c0o0f0c0gx0g0f0h0j0j0i0001k10vx0v0l11111100(^_)
#|␉
print((eval("1\x2f2")and(9)or(13   ) )-(0and 4)^1<<(65)>>(62))or'(\{(\{})(\{}[()])}\{}\{}\{})'#46(8+9+9+9+9+=!)#1111|=/=1/24=x=9[<$+@+-@@@@=>+<@@@=>+<?#>+.--.]/
__DATA__=1#//
#.\."12"␉*
###; console.log  39
""""#//
=begin␉//
#mmeeaeueewuuw*/
#define␉z  sizeof 'c'-1?"38":"37"
#include<stdio.h>
int main()  /*/
#()`#`\'*/{puts(z);}/*'``
$'main'␉//
#-3o4o#$$$
<>"3"O.<␉>//
#
=end   #//
"""#"#//
#0]#echo 21#/(\[FAC,1<-#2FAC,1SUB#1<-#52FAC,1SUB#2<-#32FACLEGEREEX,1PLEASEGIVEUPPLEASE)  a>>>
#>27.say# /7Jn~15o|  
#8␛dggi2␛`␉|1|6$//''25  =#print(17) ###^_^_LEintnd"3"z!]/*///@!32*<>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 (Versatile Integer Printer): 0.01255 (snippet in answer 40 checks this for all answers)

Rundown

This program prints 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. You can test Reng here and Modular SNUSP here; they output 19 and 31 respectively, as required. Incident is checked by keeping the tokens balances as described in previous answers.

Explanation

I looked at adding evil based on @Chance's recommendation. It slipped in quite easily and broke less things that any of my other additions did. All of evil's commands are lowercase letters. The most useful ones to note are the mark/jump related commands. There are two mark commands (m and j), two jump commands (f (forwards) and b (backwards)) and a mode toggle (x) to switch between standard and alternate marking (whether m's or j's are considered, respectively).

The f in line 2 jumps the bulk of the evil code: mmeeaeueewuuw, which is a slight tweak of the formula for generating 52 from 0 pulled off of the wiki (the accumulator is already 1 when we finish the jump, so the za wasn't needed). The extra m was to avoid creating a new token in Incident.

Working with evil moving forward

evil shouldn't be very hard to keep happy. As long as you don't create an infinite loop or add any ws, you have nothing to worry about. If you need a w, you'll need an f before it and an m or a j after it (depending on the mode when the f is reached).

Fixing things

A minor Incident

Incident was using 0m as a token, which threw evil into an endless loop. I changed that token to 0v.

Other stuff

Hexagony's code needed to be oriented the other direction to avoid bloating the byte count with padding, so a < mirror replaced the /. This required a matching > to keep perl6 happy.

For whatever reason, Japt did not like the new placement of Hexagony's }, so instead of "moving the MP to the right neighbor" I used a * to set the current edge to the product of the left/right neighbors. Since one of those is a zero, it gives us the zero at the current edge (which is all we really needed for Hexagony). Hexagony has a handful of other ways to direct the MP that also may have worked, so look into those if the asterisk becomes an issue.

And that's it. It's a little disconcerting how easy it was for evil to sneak into this polyglot.

SnoringFrog

Posted 2016-12-06T18:59:02.963

Reputation: 1 529

I just realize I accidentally left that f in line 2 from my evil attempt. Oops. It looks like your code placement avoided all the problems I saw with mine though. Well done! – Chance – 2017-02-21T22:05:32.527

9

54. Zsh, 1206 bytes

#16  "(}23!@)(" 3//*v\D@;'[af2.qc]'#)"14";n4
#/*` PkPPX (22)S"[!(>7 7*,;68*,@;'1,@␉␉␉␉ P''53'S^'q
#>␉
# >36!@␉
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++EAL+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.-- -. >][
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v0x1k\4O6O@1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k10vx0v0l111111^_)0046(8+9+9+9+9+=!)
### <$+@+-@@@@=>+<@@@=>+<?#d>+.--.|
'p\';if [[ $argv[1] == *"1"* ]];then echo 50;else echo 54;fi;exit;';print((eval("2\x2f5")and(9)or(13))-(0and 4)^1<<(65)>>(62))or"'x"or'({({1})({1}[(0)])}{1}\{1})'#}#(prin 45)(bye)|/=1/24=x/
__DATA__=1#"'x"//
#.;R"12"'
###;console.log 39
""""#//
=begin //
#sseeeemPaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#
#"`#"\'*/{puts (p);}/*'"`"
/*
<>{#65}//
#}
disp 49#//
#{
1}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo 21
#sss8␛dggi2␛ `|1|6$//''25  16*///^_^_X222999"26

Try them online!

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.

Want to learn more? Try the polygot chat!

VIP score (Versatile Integer Printer): .007665 (to improve, next entry should be no more than 1275 bytes)

Rundown

This program prints 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 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.

  • Modular SNUSP can be tested to output 31 here.

  • Incident was verified to test 33 via comparing the tokens to a previous execution (EDIT by @ais523: and subsequently confirmed to work by running it locally).

  • Deadfish~ can be tested to output 48 using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are an unavoidable consequence of running any Deadfish~ program.

Explanation

Zsh

A couple weeks ago, after I spent some time trying to run the polyglot in various languages - just trying to find something that would stick. I pulled up Zsh and found it produced the same answer as Bash.

“That’s cool,” I said aloud to a room full of otherwise productive people, and wondered more silently if it was literally reading the Bash script. So I altered the bash and found Zsh was again mirrored Bash.

So what’s going on here? Zsh and Bash are two closely related shell scripting languages. They’re so close in fact that it was a bit of a chore to find differences. Here’s the resource I found for finding those differences.

The first difference I attempted was a variable expansion that Zsh had but Bash did not. ${foo:u}returns “FOO” in Zsh, but “foo” in Bash. And so a Zsh-Bash polyglot was born.

a=a; if [[ ${a:u} == $a ]];then echo 50;else echo 54;fi;exit;

Only problem, Japt hates me, but more specifically, it hates my use of curly braces. I’d been down the Japt path enough times to know I didn’t want to do it again. So I kept looking. $#argv returned the number of arguments in Zsh, where Bash did the same, with the string argv appended. Second try:

if [[ 0 == $#argv ]];then echo 54;else echo 50;fi;exit;

Well this one worked, for everything, except Brain-Flak. Brain-flak considers everything after the # as a comment. I didn’t want to move Brain-flak, nor did I want to redo it’s stack flipping jumbo in Octave’s space, so I went back to the drawing board. $argv[1] returned [1] in Bash and the value of argument 1 in Zsh. Third time’s the charm:

if [[ $argv[1] == "[1]" ]];then echo 50;else echo 54;fi;exit;

Well, Pyth and 05AB1E didn’t like the brackets outside of what they considered a string. But that was fixable. We’d just check if $argv[1] contained a 1. Boom:

if [[ $argv[1] == *"1"* ]];then echo 50;else echo 54;fi;exit;

Great Success!

Alphuck

The s in else added another close bracket that needed a matching opening, so I added p here 'p\'; to counterbalance.

Fission: defusing the bomb

You ever have a moment while coding something where the program inexplicably works as you’d expect? That’s kind what happened here.

I found the new Bash script shifted the scripting line into a position where the D’s in the INTERCAL line no longer lined up with commands on the scripting line that inflated atomic masses or output some undesired non-sense. At least this is my presumption because I put back the __ in R"12"__* and it put the error code (that @ais523 introduced ლ(ಠ_ಠლ)) back at zero.

This is usually the point at which I throw a comment in my code to taunt my future self for having to debug my hack. But after chatting with @ais523 a bit we arrived at a solution that would be a more permanent fix.

Fission now ends in a different location from where its string is added to the stack with the purpose of terminating the program as quickly as possible – hopefully before any other atoms collide, split, or introduce bugs. The shortest time span where we can collapse the reaction and still produce a correct result is 3 tics. For example, if we add Rx_* to the polyglot, then it will synch up with R"12 by hitting the 2 and the program ending * command simultaneously. The _ here is to reduce the mass of the atom to zero since all atoms start with a mass of 1 and * outputs the colliding atom’s mass as it’s error code. The x is a space holding no-op here. I didn’t actually look up if x is a no-op, I’m just making conversation.

This gives us 1 character of flexibility to find a home in the polyglot and it turned out that adding Z_* to Cardinal’s line was generally accepted. This atom starts at the D in #=x<R+++++[D heading in the down direction. The Z makes pointer turn left, which is fortunate because Z is ignored by Minimal-2D and Cardinal, both of which traverse this character location in their 2 dimensional code paths.

Good enough for fission.

Cardinal

Cardinal had one wrinkle that had to be worked out with this Fission thing. The existing solution was 1 character too long to allow Fission to divert into a private code path, and the Fission snippet included * which is an addition operation for the tops of Cardinals two stacks. So I reworked the solution to end with the addition operation, which coincidentally is how an older version of cardinal used to work. New solution is: %++=ttt *. (extraneous no-ops removed).

And here’s a breakdown of the logic:

++ Add primary stack up to 2 [2][0]

=Copy active stack top value to secondary stack [2][2]

ttt Multiply the tops of the stacks and push the result onto the active. Three times. [4][2], [8][2],[16][2]

* Add the stacks and push the result onto the active stack. [18][2]

. Output active stack

TRIGGERED

The Z in the new fission solution is the Trigger jump code, so we need a new, unused letter. Now it’s X initiated here: PkPPX

Incident Report

I honestly don’t know what happened here. I worked the Zsh version with curly braces, got to the point of balancing for Incident, and then realized a fatal bug. After reworking everything else, Incident just seems to work. All I can say for sure is I removed the 89 detokenizing string on the last line.

Edit: the Modular SNSUP change below tokenized #<, so I threw a space between # and <

Modular SNSUP Edit

Thanks to @CalculatorFeline for pointing out that Modular SNSUP was broken!

The $ in the Bash/Zsh section broke Modular SNSUP which starts are the first $ encountered. I moved <$+@+-@@@@=>+<@@@=>+<?#d>+.--. to the line prior to it would continue to start at the correct place.

Where to go from here

This resource I found for Zsh has some other shell scripting languages with minor differences to Bash. My suspicion is that some of the other languages can be worked into the same space as Bash and Zsh without too much effort.

Good Luck

Chance

Posted 2016-12-06T18:59:02.963

Reputation: 3 169

You seem to have accidentally put in two VIP scores. – user2357112 – 2017-04-25T21:24:29.070

@user2357112 thanks. fixed. – Chance – 2017-04-25T21:30:41.663

Does Modular SNUSP work? – CalculatorFeline – 2017-04-26T16:14:52.833

@CalculatorFeline Oops. Nope, it doesn't. Fixed. Thanks. – Chance – 2017-04-26T17:31:13.023

@Chance Nope, you kept the old VIP score :P. I dropped in the correct one. – SnoringFrog – 2017-04-27T14:05:07.523

9

59. Tcl, 1324 bytes

#16  "(}23!@)(" 3//*v\D;'[af2.qc]PkPPX'#)"14";n4
#/*0|7//`"`   ['][!(>77*,;68*,@;'1,@1␉0␉␉11)(22)S␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#
#`<`
#<]+<[.>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++  L+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>+.-- -. >][4O6O@
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(}2}20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k10vx0v0l111111^_00)
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.|
#
[ "]56p26q[puts 59][exit]" ,'\[' ];#//
'(((p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A)echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f2")and 9 or 13)-(0and 4)^1<<(65)>>62)or"'x"or'{}{}{}{}({}<(((((()()())){}{})){}{})>)\{(<{}(( {}){})>)}{}({}())'#}#(prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"|/=1/24=x'/
__DATA__=1#"'x"//
#.;R"12"'
###;console.log +39
""""#//
=begin //
#sseeeemPaeueewuuweeeeeeeeeeCisajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define p sizeof'p'-1?"38":"37"
#include<stdio.h>
main ( )/*/
#*/{puts(p);}/* 
#
/*
<>{//
#}
disp 49#//
#{
}<>//
$'main'//
#-3o4o#$$$
#<R>"3"O.
=end #//
"""#"#//
#}
#s|o51~nJ;#:p'34'\=#print (17)#>27.say#]#print(47)#]#echo 21#
#sss8␛dggi2␛`|$//''25  16*///~-<~-<~-<<<~-^_^_X2229996

is a literal tab, a literal ESC character; Stack Exchange would mangle the program otherwise. Note also that the line #*/{puts(p);}/* has a trailing space. I recommend copying the program from the "input" box of the TIO link below, if you want to work on it.

Try them online!

VIP score (Versatile Integer Printer): .006446 (to improve, next entry should be no more than 1392 bytes)

Rundown

This program prints 59 in Tcl, 58 in Ksh, 57 in Wise, 56 in dc, 55 in Brain-Flak Classic, 54 in Zsh, 53 in Shove, 52 in COW, 51 in Assembly, 50 in Bash, 49 in Octave, 48 in Deadfish~, 47 in Lily, 46 in Cubix, 45 in PicoLisp, 44 in alphuck, 43 in reticular, 42 in evil, 41 in brainfuck, 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.

  • Modular SNUSP can be tested to output 31 here.

  • Incident was tested to output 33 on my own computer, locally, using the official interpreter.

  • Deadfish~ can be tested to output 48 on my own computer, locally, using this interpreter. Note that Deadfish~ takes the polyglot to be fed on stdin, but and prints a number of >> prompts to standard output, which are an unavoidable consequence of running any Deadfish~ program.

Explanation

Tcl

Tcl is a language designed for embedding scripts into larger programs. This means that there are a lot of different dialects of Tcl with different commands; however, this particular program restrains itself to "portable" Tcl, running no commands other than ones with a common meaning on every platform. (The interpreter I used for testing is tclsh, which seems to interprets unknown commands as shell commands, although it isn't documented to do so.)

In this particular program, we mostly care about its bizarre parsing rules:

  • If a token starts with #, it's a comment that lasts to a newline (thus #…\n is a comment, but x#…\n isn't;
  • Most tokens are whitespace-delimited;
  • If a token starts with { or ", it instead ends at the matching " or };
  • […] substitutes the result of a command into a token (like $(…) in bash), even if it's "…"-quoted (but not if it's {…}-quoted).

The program is thus almost very simple; all we have to do is create a "…" string literal that most languages will ignore, and drop some Tcl code in square brackets into the middle of it. In this case, that's [puts 59;exit]. However, there are some problems with this method, each of which caused a clash with a different language. As such, they'll be discussed below.

dc

Polyglotting Tcl and dc is fairly difficult, because both of them complain upon seeing an invalid command, and very few commands are valid in both. We can't start a Tcl string literal with { or " because dc will complain about both. As such, we have to start with dc code.

One possibility is to just write the dc commands outright. We can actually almost pull this off directly:

c56pq="[puts 59;exit]";

This is a valid command in the shells and in most of the scripting languages, meaning that it's almost a very simple problem to our solution. However, it isn't valid Perl (variable names in Perl start with punctuation marks, normally $), and I couldn't find a way to make it valid Perl without breaking a lot more. So that was something of a dead end.

The other alternative is to hide code from dc using square brackets to quote it, along these lines:

[ "[puts 59;exit]" ,']56pq[' ];#//

That approach seems more promising, and doesn't conflict with any of the scripting languages. (Note the space after the second "; that's for Tcl, which requires whitespace between tokens.) The shells complain, but it's a warning rather than an error (they keep executing), so we can live with this for now.

Brain-Flak Classic

There are no changes to the Brain-Flak Classic code in this polyglot. However, it's mostly relevant because of what it prevents us from doing: it doesn't let us nest square brackets, […[…]…], without producing unwanted output.

As such, our dc/Tcl polyglot is going to have to work without nesting brackets, meaning that our double-quoted string literal is going to have to contain an ] before the first [ (as it's inside square brackets itself). Perhaps surprisingly, Tcl is just fine with this; it treats [ specially, but ] isn't special except to match a [. Of course, that means we're going to have to somehow add an extra [ to the program in a way Tcl couldn't see, so that brackets stayed matched after we added an extra closing ] for Tcl (to replace the ] it couldn't see). I tried a ton of approaches for this, most of which ended up breaking some language or another (at one point I even managed to break Nim, of all things).

Eventually, I realised that you could make use of Tcl's weird comment syntax to hide a [ from Tcl but not anything else, so I added an extra couple of lines to the program for that purpose (as Tcl comments end at newlines). It was complex, though (placement is very hard, as Tcl panics upon seeing """", leaving only a small window where it could be placed, but you can fit it in just before the """" line by using single quotes to hide the whole thing from Python). Eventually, I came across the (apparently undocumented?) fact that \[ also hides the opening square bracket from Tcl, which made things much easier.

Pyth

Adding double quotes to the program is inevitably going to cause trouble with Pyth, which hides much of the program inside them (although less of the program than you might expect). The basic issue here is that Pyth, despite being a golfing language, has a distinction between expressions and statements (which is inherited from the fact that it compiles to Python); place a statement inside an expression and the program won't compile. #, which is all over the place in this program (and many copies of which actually run in Pyth) is a statement, typically meaning "loop until an exception occurs" (it's overloaded and can also mean other things, but that's the most common meaning). It uses prefix syntax and single-character commands, so apparently innocent things like our puts can end up opening a lot of nesting levels, which all have to be closed before the next #-that's-parsed is seen. However, until the next statement that's parsed, we can happily expose fairly large chunks of the program to the Pyth parser; most things are expressions, after all.

The first change we need to make to our Tcl code, which is necessarily exposed to Pyth with this way of doing things, is to remove the semicolon (which I haven't been able to figure out the exact parsing rules of, but it's statement-like and normally crashes the parser if it appears in the wrong place). We can do that via using two substitutions rather than one, [puts 59][exit] rather than [puts 59;exit].

The second change we need to make the polyglot work again in Pyth is to end the expression before the next statement occurs. As a prefix language, most of the time we can escape one nesting level via adding a literal (such as a number, or a string); that's how prefix languages work. It turns out that there are plenty of Pyth literals in the parsed area, so many of the levels close themselves naturally.

However, Pyth also has some variable-arity commands, which will consume arbitrarily many literals, and thus need to be closed explicitly. The command to do this is ), which is unfortunately one of the hardest characters to fit into the polyglot (especially as ( is a variable-arity command in its own right). Still, I perservered with this approach, adding ")3)3)" (i.e. dropping out of the Pyth string literal, cleaning up our expression, and going back into the literal), and Pyth started working. Of course, that broke a lot of other languages, and I'll be discussing those later.

I made heavy use of this Pyth debugger while working on the program; check the "Debug on?" box, and you'll see the Python that the program transpiles to. This is very helpful in knowing whether a syntax error is in the original Pyth or the output Python, and getting clues in how to fix it (e.g. if a Python statement has been placed in the middle of an expression, you know you'll need to escape some of the expression's nesting levels).

05AB1E

There are two languages which hide most of the code in strings. One of them was Pyth, but the other is 05AB1E.

Luckily, 05AB1E is much better-behaved than Pyth, and will happily tolerate almost any character in parsed code. The character that causes the problems is the q in the dc code, which prints the top of the stack and exits the program, meaning it never reaches the 26 at the end of the program.

Well, this seems more like an opportunity than a problem, given that 05AB1E's accidental new behaviour is very close to the behaviour we'd actually want. A quick change of 56pq to 56p26q and we have a clean dc/05AB1E parallel-code (i.e. all commands executed in both) polyglot that halts the parser for the rest of the code, and dc and 05AB1E naturally end up in the same place (but for different reasons). This also means that the 05AB1E code at the end of the polyglot could safely be removed, simplifying it a bit. (This may open up new opportunities for anything that cares about the end of the program.)

Underload

I added a lot of closing parentheses to the program to keep Pyth happy. Obviously, Underload likes its parentheses matched. This was a trivial fix; just add some opening parentheses just before the double quote before the Pyth code, and Pyth won't be able to see them but Underload will.

Prelude

Of course, all this addition of parentheses is something that can easily course major problems with Prelude. This is what determined where I added the Pyth/Underload code: just before the Thutu, at the end of the longest line of the program (just after the Prelude runs). Because it's on such a long line, the new parentheses don't vertically align with anything; and the )(…) acts as a Prelude comment (for exactly the same reason that ][…] acts as a comment in brainfuck/SMBF).

bash/zsh/ksh

The Pyth/Underload addition adds a double quote to the program, in a section of the code which uses double quotes to hide code from the shells. This is easier to fix than it seems; just add '3 just after the opening double quote (the extra 3 is to close the nesting level that the ' opens in Pyth), and ' near the end of the Thutu code, meaning that we can actually end the parse in these languages a line earlier than we previously were. Some proportion of the "'x" on the line afterwards can likely now be golfed off (perhaps even the whole thing!), but I don't really want to mess about more with this now that it's working.

Incident

I needed to detokenise three tokens to balance the code. Coffeescript's 39 became +39 to break up 3, a space was dropped into the Brain-Flak to break up ({}, and a trailing space was added to the C (specifically, #*/{puts(p);}/* ) to break up the token consisting of /* and a newline.

Future prospects

The end of the code is now much more open than it previously was. I don't know which languages care about that, but if you can think of one, now is a good opportunity.

Tcl shouldn't cause problems past the first non-# line, as all previous lines are commented out, and the parser exits before parsing any more.

Double quotes are now more usable than they previously were, because both Pyth and 05AB1E have had changes to make them more tolerant of double quotes in the code. (The ((("'3)3)3) can easily be expanded if needed to close more levels of Pyth code, without negatively affecting anything else.) This probably increases the scope for adding more #-comment languages that don't have usable block comments.

user62131

Posted 2016-12-06T18:59:02.963

Reputation:

I told Chance this but the # at the end of the second to last line is totally unnecessary. I put it in earlier (it was needed then) but it can be removed now. – Wheat Wizard – 2017-05-03T18:55:19.620

There's likely a lot of unnecessary code here; for example, the #\n#\n is very suspicious. I guess some time, someone's going to go round and golf it all off. (Perhaps while adding a particularly verbose language, to save VIP headroom.) – None – 2017-05-03T18:57:32.997

actually, #\n#\n is for labyrinth. I forgot to document that one in my last Japt refactor. – Chance – 2017-05-03T20:27:52.897

9

68. Python (1.6.1), 1698 bytes

#16  "(}o+?23!@)-("//*\Dv;'[af2.q]PkPPX'#CO)"14";n4
#/*0|7//```"`   [-'v][!(>77*,;68*,@;'1,@10␉␉11)(22)S␉␉(1 P''53'S^'q
#>␉
# 36!@␉`
#
#_>++++.>++++++::@-----x-.+?
#`<`
#<]}} +<[<.>>-]>[
#{
#z}
#
#=x<R+++++[D>+++++++59xL+++<-][pPLEASE,2<-#2DO,2SUB#1<-#52DO,2SUB#2<-#32DOREADOUT,2PLEASEGIVEUPFACiiipsddsdoh]>@@+.---4O6O@.>][
#
#x
#x%+>+=ttt Z_*.
#D>xU/-<+++L
#R+.----\).>]|
#[#[(?2?20l0v0x1k1kMoOMoOMoOMoOMOO0l0ix0jor0h0h1d111x0eU0yx0y0moO1d0y0e0e00m1d0i0fx0g0n0n11MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOmOoMOo0moo0n0tx0t0moO0f0t0gOOM0g0f0h0j0j0i0001k1x0vx0v0l111111^_00)
[ "]56p26q[puts 59][exit]" ,'\[' ];#/s\\/;print"24";exit}}__DATA__/
#
###x<$+@+-@@@@=>+<@@@=>+<?#d>+.--.
#
'((( p\';a=a;case $argv[1]+${a:u} in *1*)echo 50;;*A )echo 54;;*)echo 58;;esac;exit;';print((eval("1\x2f 2")and 9or 13<<(65)>>65or 68)-(0and 4)^1<<(65)>>62)or"'x"or' {}{}{}{}({}<(((((()()())){}{}) ){}{})>){(<{}(({}){})>)}{}({}())wWWWwWWWWwvwWWwWWWwvwWWWwWWWWWWWWwWWWWwWWWWWWWwWWWWWWWW li ha '#}#( prin 45)(bye)46(8+9+9+9+9+=!)((("'3)3)3)"'
__DATA__=1#"'x"
#.;R"12"'
###;console.log 39
""""
=begin
<>{nd
#sseeeemPaeueewuuweeeeeeeeeeCis:ajjap*///;.int 2298589328,898451655,12,178790,1018168591,84934449,12597/*
#define u8 "38\0"
#define p sizeof'p'-1?u8"67":"37"
#include<stdio.h>
main ( ){puts( p);}/*
print 61
#}
disp 49;
#{
}<>
$'main'3
#-3o4o#$$$
#<T>"3"O.s
=end
"""#"
#}
#sx|o51~nJ;#:p'34'3\=#print(17)#>27.say#]#print (47)#]#echo 21# xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi xi ax fwwvwWWWwWWWWwvwWWwWWWwvwWWwWWWwvwWWwWWWwvwWWwwwwwwwwwwwWWWwWWWWWwWWWWWWWwWWWWWWWWWwWWWWWWWWWWWWWWWwWWWWWWWWWWWWwvm 
# sss8␛dggi2␛`|$// ''25  16*///~-<~-<~-<<<~-XCOprint("65")#s^_^_2229996#

VIP score (Versatile Integer Printer): .005400 (to improve, next entry should be no more than 1773 bytes)

Try it online!

Rundown

This program prints 1 in Python 3, 2 in V/Vim, 3 in Minkolang, 4 in ><>, 5 in Python 2, 6 in SMBF, 7 in Japt, 8 in Retina, 9 in Perl 5, 10 in Befunge-93, 11 in Befunge-98, 12 in Fission, 13 in Ruby, 14 in Turtlèd, 15 in Haystack, 16 in Pyth, 17 in Julia, 18 in Cardinal, 19 in Reng, 20 in Prelude, 21 in Nim, 22 in Underload, 23 in Hexagony, 24 in Thutu, 25 in Pip, 26 in 05AB1E, 27 in Perl 6, 28 in Brain-Flak, 29 in Trigger, 30 in Whitespace, 31 in Modular SNUSP, 32 in Whirl, 33 in Incident, 34 in Rail, 35 in INTERCAL, 36 in Labyrinth, 37 in C++, 38 in C99, 39 in CoffeeScript, 40 in Minimal-2D, 41 in brainfuck, 42 in evil, 43 in reticular, 44 in alphuck, 45 in PicoLisp, 46 in Cubix, 47 in Lily, 48 in Deadfish~, 49 in Octave, 50 in Bash, 51 in Assembly, 52 in COW, 53 in Shove, 54 in Zsh, 55 in Brain-Flak Classic, 56 in dc, 57 in Wise, 58 in Ksh, 59 in Tcl, 60 in Moorhens, 61 in S.I.L.O.S, 62 in Grass, 63 in Brian & Chuck, 64 in Agony, 65 in ALGOL 68, 66 in Surface, 67 in C11 68 in Python

Verification

Most languages can be tested with the test driver above, but 6 languages have to be tested locally.

  • Reng can be tested to output