# Anaglot Polygrams

Write some code that can be rearranged into n different programs in n different languages each outputting a distinct number from 1 to n.

No two languages should be the same however different versions of "the same language" will be considered distinct languages, as long as they have different major version numbers. For this challenge REPL environments are not distinct from their parent languages but are still a language. Each language should run on a distinct permutation of the source code and output a distinct number in the range.

Permutations will be counted in bytes not in characters.

You should include each permutation that is run with the language that it is run in for testing purposes.

# Scoring

Where N is the number of languages and L is the number of unique orderings of the programs bytes.

L is not equal to the length of the program

(unless the program is 1 or 0 bytes)

Here is a python script to calculate L courtesy of Conor O'Brien.

L is equal to the length of the program factorial if and only if there are no repeated bytes in the program.

The goal is to maximize your score.

• Related. Commented May 9, 2017 at 19:00
Commented May 9, 2017 at 19:05
• @Adám There would be no reasonable way to ban comments Commented May 9, 2017 at 19:06
• So if # is the comment symbol in 5 languages, good solution would be 1#2345
Commented May 9, 2017 at 19:06
• @Adám that gives you a score of 1/6. I'm sure a score of 1 is easily possible with a 2-byte program (or a 1-byte program for that matter). And adding more digits reduces your score. Commented May 9, 2017 at 19:08

# 34 Languages, 19 bytes, Score: 38,832,018,459,912,437,760,000

Here is a quick answer I threw together to show that it is possible to get an answer scoring better than 1.

 12233echo*+--@#..;


## 1. NTFJ

#*22331+..@o;-- ech


This outputs via character code, which is allowed by meta consensus.

Try it here

## 2. Tcsh

echo 2;#..1@2+33*--


## 3. 05AB1E

2231*+..@echo ;--#3


Try it online!

## 4. Actually

@..o; eho1#c3223-*+-


Try it online!

## 5. Befunge 98

[email protected]*#3o;-- ech


Try it online!

## 6. Cubix

123+23*o@#;-- ech..


Outputs by character code

Try it here

Unfolded code:

    1 2
3 +
2 3 * o @ # ; -
- e c h . . . .
. .
. .


3+2*2 --31#;@..echo


## 8. Seriously

@..o; eho1#c3223-+*-


Try it online!

## 9. ><>

33*o;2+..@#12-- ech


Outputs by character code

Try it online!

## 10. Befunge

33*1+.@.#22o;-- ech


Try it online!

## 11. brainbool

323*+..@echo ;--#12


Try it online!

## 12. 2sable

233*+..@echo ;--#12


Try it online!

## 13. Hexagony

13;2#2+@*3o-- ech..


Outputs by character code

Try it online!

Unfolded code:

  1 3 ;
2 # 2 +
@ * 3 o -
- e c h
. . .


## 14. R

12+2#*33..@o; ech


Try it online!

## 15. bc

12+3#*23..@o;-- ech


## 16. Python 3 REPL

13+3#*22..@o;-- ech


## 17. irb (Ruby 2.4 REPL)

13+2*2#3..@o;-- ech


## 18. PowerShell

12+2*3#3..@o;-- ech


## 19. Python 2 REPL

13+2*3#2..@o;-- ech


## 20. Python 1.6.1 REPL

23-3#-+*21..@o; ech


## 21. Ksh

echo 21;#..2@3+3*--


## 22. Bash

echo 22;#..1@3+3*--


## 23. Zsh

echo 23;#..1@2+3*--


## 24. Applescript

23+1 --#2*3..@o;ech


## 25. Lua REPL

23+2 --#1*3..@o;ech


## 26. Julia REPL

23+3 #2*1..@o;--ech


## 27. irb (Ruby 1.9.3 REPL)

13*2+3-2 #..@o;-ech


13*2+2--3#;@.. echo


## 29. J

echo --1#.23;@+2*.3


Try it online!

## 30. Nim

echo 33-2-1;#..@2+2*


## 31. fish

echo 31;#3-2-..@2+2*


## 32. PHP

echo 32;#+123*@..--


<?php is not needed due to this meta

Try it online!

## 33. Golfscript

3.#.1223*@+o;-- ech


Try it online!

## 34. Octave

33+1 #22echo*--@..;


Try it online!

• And that's why I hate REPL-capable languages Commented May 9, 2017 at 20:03
• If you add . and another language, you can have 11. J: 2#.2+3*3 Commented May 9, 2017 at 21:17
• @WheatWizard here Commented May 9, 2017 at 21:47
• @WheatWizard FWIW, all valid J permutations Commented May 9, 2017 at 21:48
• @WheatWizard J is technically a REPL. Prefix the code with echo  to see the output. Commented May 9, 2017 at 21:50

# 1 language, 0 bytes, score 1

I don't know how high scores will get in this challenge, so let's take this spot.




Try it online!

In Retina, the empty program with no input prints 1.

Score = 1!/0! = 1/1 = 1

• This looks at first glance like a joke answer, but has the highest score so far... Commented May 9, 2017 at 19:28
• Same score for a 1 byte single language entry, no?
Commented May 9, 2017 at 19:30
• @Adám yeah, like 1 in R, for example Commented May 9, 2017 at 19:32
• In jelly, this outputs 0, so 2 languages => score=2 Commented May 9, 2017 at 19:34
• @Mr.Xcoder No that is not how the scoring works. You must output 1 through n and each should be on a separate permutation. Commented May 9, 2017 at 19:53

## 2 languages, 2 bytes, score 1

Doesn't beat Leo's answer, but I thought I'd present a 2-language solution (well, and Wheat Wizard ninja'd a score-2 answer in between anyway).

### Retina, prints 1

2


Try it online!

This is essentially the same as Leo's empty program.

### Pyth, prints 2

2


Try it online!

This is repr(2) so it computes "2" which gets printed as 2.

# 26 languages, 46 bytes, Score : 1.68861953e-28 (0.000000000000000000000000000168861953)

All the languages are mainstream ones (i.e. they are actually used by people in development) and there's no REPL solution in any language. This answer is never going to win, but that's not a reason for not posting it...

//#**print()ale123456789+chous :f{}:""enttd *;


## 1. Python 2

print 1#//**()alechous:f{}:23456789+ ""enttd*;


Try it online!

## 2. Python 3

print(2)#//**alechous13456789+: f{}: ""enttd*;


Try it online!

## 3. Ruby

puts 3#//**()alecho:f12456789+{}rin: ""enttd*;


Try it online!

## 4. CoffeeScript

alert 4#//**()pinchous:12356789+f{}: ""enttd*;


Try it online!

## 5. PHP

echo 5/*alrt#()pinus:f{:12346789+} ""enttd;**/


Try it online!

## 6. Perl 5

print 6#/*ale()chous:12345789+f{:} */""enttd*;


Try it online!

## 7. Perl 6

print 7#/*ale)(chous:f12345689+{:} */""enttd*;


Try it online!

## 8. JavaScript (ES5)

alert(8)//pin 12345679+#*chous:f{:} *""enttd*;


Try it online!

## 9. JavaScript (ES6)

alert(9)//inp 12345678+#*chous: f{:}*""enttd*;


Try it online!

## 10. JavaScript (ES7)

alert(9+1)//pni #*chous2345678: f{:}*""enttd*;


Try it online!

## 11. Batch

echo 9+2 ::alrt()//pni#*usf{1345678}*""enttd*;


Couldn't find an online interpreter for this one. Try running this code in the Command Prompt, if you are on Windows.

## 12. Bash

echo 12 #::alrt(3456789+)//pni*usf{}*""enttd*;


Try it online!

## 13. CSS

*:after{content:"13" /*h# l(2456789+)pisud;*/}


Try it online!

## 14. Less

*:after{content:"14" /*#h l(2356789+)pisud;*/}


Try it online!

## 15. Stylus

*:after{content:"15" /*#hl (2346789+)pisud;*/}


Try it online!

## 16. TypeScript

alert(16)//inp #*chous2345789+: :{f}*""entt*d;


Try it online!

## 17. Octave

disp(17)#//n *chou2345689+: :{f}*""entt*alert;


Try it online!

## 18. Swift

print(18)//ds# *chou2345679+: :{f}""ent*ale*t;


Try it online!

## 19. Julia

print(19)#ds// *chou2345678+: :{f}""ent*ale*t;


Try it online!

## 20. Maxima

print(18+2);/*#ds ouch 345679::{f}""entale*t*/


Try it online!

## 21. Clojure

(print "21");/*#ds ouch3456789+::{f}entale*t*/


Try it online!

## 22. Groovy

print 19+3//();*#ds oh245678::{fuc*}entalet*""


Try it online!

## 23. CommonLisp

(print 23);//*#ds oh1456789+::{fuc*}entalet*""


Try it online!

## 24. EmacsLisp

(print 24);//*#ds oh1356789+::{fuc*}entalet*""


Try it online!

## 25. PicoLisp

(print 25);//*#ds oh1346789+::{fuc*}entalet*""


Try it online!

## 26. Logo

print 21+5 ;//*#dsoh346789::{fuc*}entalet*""()


Try it online!

• And Swift, displaying 18: print(18)//#**alechous: f{}:2345679+ ""enttd* Commented May 10, 2017 at 10:23
• Suppose this will increase your score by about 0.002e-20 :)) Commented May 10, 2017 at 10:30
• pfft. 2017 will be the year of the Befunge Web Framework! Commented May 10, 2017 at 13:28
• Comments are just going to turn this entire question into insanity… Commented May 10, 2017 at 19:32
• btw Applescript which can be seen in my answer works without a REPL, but does require -- for comments. If you add -- you can probably also work in at least one type of haskell. Commented May 11, 2017 at 6:59

## 12 Languages, 16 Bytes - Score: 0.003

print(0b11000)#1


Prints 1 in 2sable

print(0b1100)#10


Print 10 in 05AB1E

print(0b11)#1000


Re-arranging the binary numbers prints 2-9, 11-12 in:

• Crystal
• Julia 0.5
• J-uby
• Lily
• Perl 5
• Perl 6
• Python 3
• Python 2
• Python
• Ruby

L=145297152000 12! = 479001600

I just used TiO for a list of valid languages for this (If these are all considered unique?). Removed some duplicate languages thanks to input from Wheat Wizard. This answer is looking pretty low, though I feel it has potential.

• Julia 0.4 and 0.5 have the same major version number. And so does Python 2 (PyPy) and Python 2. However this will probably work in Python 1 Commented May 9, 2017 at 21:05
• Can you leave off the print and call it repl? How many of these have repls? Commented May 10, 2017 at 5:42
• @BrianMcCutchon Lily, Perl, and Crystal do not have repls. All the other ones do. Commented May 11, 2017 at 7:09

# JavaScript (ES6), Python 2, Python 3, Japt, 4.735e-15

# ()//1234=>inprt


## ES6 (1)

p=>1//rint 234()#


## Python 2 (2)

print 2#134=>//()


## Python 3 (3)

print(3)# 124=>//


## Japt (4)

#rint>=3/2)p (4/1

• Your score is 4.73508590206e-15 btw. Commented May 9, 2017 at 19:22
• Is it? 4 factorial is 24. That divided by 17 is roughly 1.4
– Luke
Commented May 9, 2017 at 19:23
• Not divided by 17 but by 5068545850368000, the number of ways to rearrange the string. Commented May 9, 2017 at 19:24
• Oops. Misread that. Thanks for pointing it out.
– Luke
Commented May 9, 2017 at 19:25
• @WheatWizard Ouch, I missed that too.