6
\$\begingroup\$

You need to write a program in any language that will produce (source code for) a program in a different language. That program will produce a 3rd program in another language and so on.

You should aim to create many programs; you aren't limited to 3. You can re-use a language, but it won't be counted in the scoring.

Your entry is the source code of the first program, together with a list of the languages of subsequent programs produced in the order they are produced. For easy reading maybe include each program's output/source.

Scoring will be the length of the source code of the first program divided by the number of different languages used.


To prevent solutions such as 1 (that has been pointed out in the comments) I suggest the following extra rule:

The output of one program must not be valid code in the language of that program.

\$\endgroup\$
  • 9
    \$\begingroup\$ You do know that 1 is at the very least a Golfscript program that outputs a PHP program that outputs an APL program that outputs a J program that outputs a Perl program that outputs nothing, right? \$\endgroup\$ – marinus Jul 16 '13 at 12:04
  • 9
    \$\begingroup\$ Or what about this non-trivial quine version, going through 50 languages: github.com/mame/quine-relay \$\endgroup\$ – daniero Jul 16 '13 at 12:52
  • \$\begingroup\$ Similar to codegolf.stackexchange.com/questions/2582/golf-a-mutual-quine \$\endgroup\$ – Peter Taylor Jul 16 '13 at 13:22
  • \$\begingroup\$ @marinus: maybe I should add a rule that states the source code produced for the next language must be invalid in the one producing it. \$\endgroup\$ – George Duckett Jul 16 '13 at 13:35
  • \$\begingroup\$ @marinus: I'm curious what your point is. Are you suggesting that nobody should pose a challenge which can be trivially accomplished with GolfScript? That would make most challenges moot, and render this stackexchange site pointless. Is it perhaps better to consider non-GolfScript solutions worthwhile in spite of the existence of GolfScript? \$\endgroup\$ – Igby Largeman Jul 17 '13 at 3:57
3
\$\begingroup\$

Clojure → C → Python 2.7 → BASIC → Bash

Score: 13.40

(println"int main(){puts(\"print'PRINT\\\"echo\\\"'\");return 0;}")

Here is the breakdown:

  1. Clojure

    (println"int main(){puts(\"print'PRINT\\\"echo\\\"'\");return 0;}")
    
  2. C

    int main(){puts("print'PRINT\"echo\"'");return 0;}
    
  3. Python 2.7

    print'PRINT"echo"'
    
  4. BASIC

    PRINT"echo"
    
  5. Bash

    echo
    

I guess a simpler alternative would be

print'echo'

in Python 2.7, which outputs Bash code. This has a score of 5.5, but isn't as fancy as what's above.

\$\endgroup\$
12
\$\begingroup\$

My first time for that kind of challenge:

R > Julia > BrainF**k - 91 characters - Score: 30.33

The initial R code:

cat("'+'^8","\"[>\"","'+'^9","'>'","'+'^13","'>'","'+'^4","'<'^3","\"-]>.>+.>+.\"",sep="*")

It produces the following Julia code:

'+'^8*"[>"*'+'^9*'>'*'+'^13*'>'*'+'^4*'<'^3*"-]>.>+.>+."

Which produces:

++++++++[>+++++++++>++++++++++++++>++++<<<-]>.>+.>+.

which equates to:

Hi!

in BrainF**k.

NB: None of the three programs is valid in any of the two other languages.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.