Golfing Relay Race

6

1

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.

George Duckett

Posted 2013-07-16T11:21:26.720

Reputation: 163

9You 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? – marinus – 2013-07-16T12:04:55.663

9

Or what about this non-trivial quine version, going through 50 languages: https://github.com/mame/quine-relay

– daniero – 2013-07-16T12:52:25.370

Similar to http://codegolf.stackexchange.com/questions/2582/golf-a-mutual-quine

– Peter Taylor – 2013-07-16T13:22:44.617

@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. – George Duckett – 2013-07-16T13:35:31.280

@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? – Igby Largeman – 2013-07-17T03:57:41.280

Many languages accept bare numbers as valid programs that output that number. It has nothing to do with Golfscript per se. – breadbox – 2013-07-17T07:51:42.733

@IgbyLargeman, surely by definition anything which can be "trivially accomplished" isn't a challenge? – Peter Taylor – 2013-07-17T08:24:28.973

@IgbyLargeman: I was just pointing out a loophole in the question that would allow trivial answers like 1 to win, because that would make the question uninteresting. George has indeed fixed it now. – marinus – 2013-07-17T10:59:32.600

Wow. Did anyone look at the source of the quine-relay? It is even ascii art. – Johannes Kuhn – 2013-07-17T21:48:37.077

Answers

3

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.

arshajii

Posted 2013-07-16T11:21:26.720

Reputation: 2 142

12

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.

plannapus

Posted 2013-07-16T11:21:26.720

Reputation: 8 610