Anaglot Polygrams

19

0

Task

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

Your score will be the

Scoring equation

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.

Post Rock Garf Hunter

Posted 2017-05-09T18:56:29.373

Reputation: 55 382

Related. – Martin Ender – 2017-05-09T19:00:13.947

are comments allowed? – Adám – 2017-05-09T19:05:11.167

@Adám There would be no reasonable way to ban comments – Post Rock Garf Hunter – 2017-05-09T19:06:28.763

So if # is the comment symbol in 5 languages, good solution would be 1#2345 – Adám – 2017-05-09T19:06:31.437

@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. – Martin Ender – 2017-05-09T19:08:28.800

https://en.wikipedia.org/wiki/Four_fours maybe? I don't know enough programming languages to work this out for myself but repeating characters doesn't cost you as much in the denominator. – Giuseppe – 2017-05-09T19:44:13.760

Does it have to be distinct numbers from 1 to n? Can we just output distinct integers? – Rɪᴋᴇʀ – 2017-05-09T19:51:10.650

@Riker No they have to be 1-n – Post Rock Garf Hunter – 2017-05-09T19:52:01.543

You might want to use this revised script, which allows for longer texts to be used

– Conor O'Brien – 2017-05-09T22:09:44.793

Answers

30

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

23+.@.21*#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 . . . .
    . .
    . .

7. Haskell 8 REPL

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

28. Haskell 7 REPL

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!

Post Rock Garf Hunter

Posted 2017-05-09T18:56:29.373

Reputation: 55 382

5And that's why I hate REPL-capable languages – Mr. Xcoder – 2017-05-09T20:03:45.270

1If you add . and another language, you can have 11. J: 2#.2+3*3 – Conor O'Brien – 2017-05-09T21:17:12.743

@WheatWizard here

– Conor O'Brien – 2017-05-09T21:47:48.167

1

@WheatWizard FWIW, all valid J permutations

– Conor O'Brien – 2017-05-09T21:48:13.877

@WheatWizard J is technically a REPL. Prefix the code with echo to see the output. – Conor O'Brien – 2017-05-09T21:50:45.617

Nice! +1 BTW, I am not too behind! :)

– Arjun – 2017-05-10T03:47:53.957

Even more TIO links: Python 3, Python 2, zsh, Lua, Julia, Ruby, Haskell (not sure how to do this one)

– ASCII-only – 2017-05-11T10:21:03.570

Also ksh, bash (also not sure about the ruby one in the last comment, probably the wrong version)

– ASCII-only – 2017-05-11T10:28:28.577

echo+32;#123*@.-- PHP anyone? – Christoph – 2017-05-11T12:19:02.263

Will you stop, please !!!! No one can beat that, never! – Arjun – 2017-05-11T15:36:08.787

@WheatWizard We usally don't use the tags when golfing (only if we use it to output like <?=) because you can run code using php -r without the tags. There's some meta for that if I find the time I will link it. – Christoph – 2017-05-11T16:27:36.583

@WheatWizard Relevant meta.

– Christoph – 2017-05-11T16:56:31.610

11

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

Leo

Posted 2017-05-09T18:56:29.373

Reputation: 8 482

7This looks at first glance like a joke answer, but has the highest score so far... – trichoplax – 2017-05-09T19:28:19.587

Same score for a 1 byte single language entry, no? – Adám – 2017-05-09T19:30:35.857

@Adám yeah, like 1 in R, for example – Giuseppe – 2017-05-09T19:32:12.160

@Giuseppe Or any other language that outputs numbers without any specific command like echo or print. – Adám – 2017-05-09T19:32:48.973

5In jelly, this outputs 0, so 2 languages => score=2 – Mr. Xcoder – 2017-05-09T19:34:44.653

5@Mr.Xcoder No that is not how the scoring works. You must output 1 through n and each should be on a separate permutation. – Post Rock Garf Hunter – 2017-05-09T19:53:53.907

Where's your TIO link? – Neil – 2017-05-10T00:08:06.590

Um, the score is infinity (or NaN), not 1. – Steve Bennett – 2017-05-10T05:15:46.067

@Steve Nope. The number of permutations of a length 0 program is 0! = 1. – Brian McCutchon – 2017-05-10T05:39:59.150

Oh, I just learnt something, thanks. – Steve Bennett – 2017-05-10T05:48:10.960

6

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.

Martin Ender

Posted 2017-05-09T18:56:29.373

Reputation: 184 808

5

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!

Arjun

Posted 2017-05-09T18:56:29.373

Reputation: 4 544

1And Swift, displaying 18: print(18)//#**alechous: f{}:2345679+ ""enttd* – Mr. Xcoder – 2017-05-10T10:23:36.803

Suppose this will increase your score by about 0.002e-20 :)) – Mr. Xcoder – 2017-05-10T10:30:09.890

3pfft. 2017 will be the year of the Befunge Web Framework! – Skyler – 2017-05-10T13:28:41.483

Comments are just going to turn this entire question into insanity… – Mathime – 2017-05-10T19:32:58.713

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. – Post Rock Garf Hunter – 2017-05-11T06:59:24.213

You also don't need all the characters you have 6 can be replaced with 2*3 in the first instance and 8*2 when it is being used to make 16. You could probably do the same with some of the other digits. (I see you have already dumped 0) – Post Rock Garf Hunter – 2017-05-11T07:01:24.643

Right now I think you should aim to minimize the number of characters in your source, removing a single character will currently multiply your score by 44. Grouping characters is also not a bad idea, In my answer I repeat 2 and 3 because repeats contribute less to the count. – Post Rock Garf Hunter – 2017-05-11T07:06:17.263

Ruby has print btw, so you don't need the u from the puts. If you use printf in bash and print in batch, you can also get rid of some characters there. (cho) – Post Rock Garf Hunter – 2017-05-11T07:12:28.363

@WheatWizard Thank you so much for the suggestion (and the upvote! :)) But, unfortunately, I can't implement them. Doing so will require me to update all the TIO links that I have linked to in my answer before reading your comments, as well as updating all the solutions. I, currently, don't posses enough potential to perform that! Sorry (and thanks for the upvote; that really lifted my spirits; as I was thinking "What the hell did I add those 9 more languages and revised TIO links for?!") I hope you'll understand my predicament! Sorry (and thanks for the upvote!), once again! :) Thanks for.... – Arjun – 2017-05-11T08:03:10.533

....reading such long comment too! :) @WheatWizard – Arjun – 2017-05-11T08:05:07.573

@Mr.Xcoder Thanks for that! Added it! Along with it, I have added 8 more languages too (excluding Swift)! But that only made my score worse! :p – Arjun – 2017-05-11T08:06:43.940

@Mathime Added 9 more languages! Have a look! – Arjun – 2017-05-11T08:07:42.527

@Skyler I don't get what you mean! Could you explain, please! Sorry, if it's too obvious! :p – Arjun – 2017-05-11T08:09:32.690

3

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.

qoou

Posted 2017-05-09T18:56:29.373

Reputation: 711

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 – Post Rock Garf Hunter – 2017-05-09T21:05:49.843

Can you leave off the print and call it repl? How many of these have repls? – Brian McCutchon – 2017-05-10T05:42:22.660

@BrianMcCutchon Lily, Perl, and Crystal do not have repls. All the other ones do. – Post Rock Garf Hunter – 2017-05-11T07:09:35.047

1

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

Luke

Posted 2017-05-09T18:56:29.373

Reputation: 4 675

Your score is 4.73508590206e-15 btw. – Post Rock Garf Hunter – 2017-05-09T19:22:31.723

Is it? 4 factorial is 24. That divided by 17 is roughly 1.4 – Luke – 2017-05-09T19:23:39.887

Not divided by 17 but by 5068545850368000, the number of ways to rearrange the string. – Post Rock Garf Hunter – 2017-05-09T19:24:37.507

Oops. Misread that. Thanks for pointing it out. – Luke – 2017-05-09T19:25:44.990

@WheatWizard Ouch, I missed that too. – Adám – 2017-05-09T19:26:44.330

I don't know how it would affect the Japt answer, but you could switch Python2 to print 1 with 4/3 to save 1 byte – Rod – 2017-05-09T19:32:48.280

As I calcuated, your score is actually 1,3495e-13, because there are 177843714048000 permutations according to the script provided. – Mr. Xcoder – 2017-05-09T20:02:44.220