\$\begingroup\$

55. Brain-Flak Classic, 1266 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 ###<$+@+-@@@@=>+<@@@=>+<?#d>+.--.| '(p(p0 \';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

Try it 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.

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

Rundown

This program prints 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 on my computer.

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.

Brain-Flak Classic does have a TIO but should be verified to run using this interpreter as the TIO interpreter post-dates the challenge.

Explanation

This is my first submission to this challenge, since someone has already done Brain-Flak I have to throw Brain-Flak Classic into the mix.

Brain-Flak Classic

Brain-Flak classic is the original Version of Brain-Flak. It has several key differences from regular Brain-Flak.

[n] prints n instead of returning -n

prints n instead of returning [] returns -1 instead of the stack height

Our main competator is thus Brain-Flak itself, due to the increadable overlap. We then have to exploit one of the two differences.

We simply cannot abuse [...] because as soon as Classic sees [...] it will print something and that is a problem. instead we have to use [] to differentiate between the two. If the stack is empty [] will return a truthy value in Classic (-1) and a falsy value in Brain-Flak (0). Since standard if syntax works in both languages we can use this to create an two different numbers in the two languages. Here is the code I came up with:

([]<(((((()()())){}{})){}{})>){(<{}(({}){})>)}{}({}())

Try it online!

This pushes 27 doubles it if it detects Classic and adds one. It is quite convenient that the language numbers were so close to a multiple of 2 off.

Zsh

I began work on this submission while @Chance was working on implementing Zsh. I hoped that it would not be an issue, but it immediately was. See the Zsh Bash polyglot utilizes an if statement that looks like this:

if [[ $argv[1] == *"1"* ]];

If we look at this the way Brain-Flak sees it:

[[ [ ] ]]

There is no problem, this evaluates as 0 and makes no changes to the stack. Even if it made anychanges to the stack those could be wiped with a couple of {} and we could be on out way. However Brain-Flak Classic sees this differently, Classic sees print -1 twice which is really bad; no amount of {} will ever unprint anything so we need to get rid of the square braces.

Not knowing Zsh or bash it took me a bit but I was able to replace the if statement with a case statement that looks like this

case $argv[1] in *1*)echo 50;;*)echo 54;;esac;exit;

This is better because it doesn't print anything, but it isn't balanced because of the ) s so it errors in both the languages. This can be remidied by adding (( earlier on in the program.

Funnily enough implementing this change makes the polyglot shorter without breaking anything as far as I could tell.

Now I removed the existing Brain-Flak code (and all those weird symbols inside of it; they can't be that important right?) and replaced it with the new code.

And what would you know it it worked perfectly, the end.

except for Alphuck, Japt, Thutu, Incident, and Prelude

Alphuck

Alphuck was probably the easiest language to fix. Since both case and esac added an s two new p s had to be added to the beginning of the line to cancel them out. That was it.

Japt

Unlike alphuck, Japt was a real pain. Japt took the entire mess of parenthesis and brackets that was the new Brain-Flak code and tried its very hardest to read it as something intelligible. It failed.

The first thing Japt did not like was >) . To Japt the > was interpreted as a greater than sign with nothing to operate on to the right of it. To fix this I simply had to insert something to the right of it that Japt would interpret as an object. This can be solved by just using a one digit number.

The next thing Japt didn't like {} . To Japt this sometimes reads as:

(function(){return })

It also sometimes reads it as:

()

Which it also doesn't like

When it reads as which I am not 100% clear on but putting numbers in all of the offending {} s fixes the problem.

Next up Japt doesn't know what to do with () . Once again putting numbers in them is the way to go.

Japt was still not very happy with the code complaining about something or other, but it was printing the number so I was going to spend anymore time fixing what wasn't broken.

Prelude

All the editing on the line with the Brain-Flak has caused it to become the longest line. This means I had to move the prelude code to the end of the current line. Then Prelude began its complaints about where parentheses were located. Prelude does not allow Parentheses on different lines to be in the same column. This gets to be a problem when the code you are editting around is made almost entirely of parentheses. In fact every edit from now on is pretty much followed with and then I had to go realign all the parentheses because Prelude is complaining.

Thutu

Thutu had two main problems.

Nested quatifiers {1}{1}

[]

Nested quantifiers arises because Thutu is interpreting Brain-Flak as regex and doesn't know what to do when {...} is followed by {...} . It is fixed by putting things in between the two. It also doesn't like [] because regex. This is fixed with my favorite stategy of slapping a number inside of the braces.

Modular SNUSP

Since I was working while @Chance was the Zsh changes that broke SNUSP for him also broke it for me. I implemented a nearly identical fix for it so you can read #54 for the details.

Incident

All that was left broken was Cubix and Incident. I probably should have chosen to fix cubix first, but I didn't, I decided to go with Incident.

Incident is one of my favorite languages to fix. It requires a massive balancing act across pretty much the entire program. I'm still not clear on how Incident works. The thing I was told is that I want 0mo to be the middle token in the list of tokens.

Amazingly I seemed to in my destructive romp all over the 17th line of the program caused minimal damage to the program. The (( I added to the begining of the line caused (p to become a token. In order to fix this I changed ((pp to (p(p . This caused the parser to see (p 4 times instead of 3 and ignore it as a token. This would not be the end of Incident

Cubix

Asside from some font confusion Cubix was pretty easy to fix. Since the board had resized I just had to move the "capsule" that had conveniently been made for me by my predecessors to the right place. Because Cubix quickly became stuck in an infinite loop this was a tad tricky but I ended up being able to manage.

Prelude (again)

With the Cubix fix Prelude was back, with a vengence. Prelude had as I mentioned popped up a couple of times before but ultimately been easy to squash. This time I had to make nearly two dozen separate adjustments before Prelude would run.

Incident (again)

Of course fixing Prelude broke Incident. It created 9 new tokens that had to be removed in order to get the code to run. And of course removing the tokens once again broke Prelude. At this point It was starting to feel like Whack-a-mole, every fix I would make would break either Incident or Prelude, which of course would both break each other. After a couple rounds of back and forth I was able to get them to cooperate. The result is a delicate balance that will surely wreak havoc on the next competator.

Going forward

Dealing with Brain-Flak Classic in the future should be only slightly worse than dealing with Brain-Flak itself. The one thing it really doesn't like is [...] . These can be commented out for the most part.

I just dug up an old Brain-Flueue interpreter that predates this challenge so I think for my next attempt I will try to implement that one.