-3
\$\begingroup\$

Task

Write a program that will output another distinct program, and so on, while using as few distinct characters (and as few bytes) as possible.

For example, program 1 should output program 2, and when program 2 is executed, it should output program 3. This can be nested as deeply as needed, but must be at least 3 distinct programs deep.


Rules

  • Your program can take no input.

  • When the program is executed, the output should be the source of another, different program. This includes the STDERR stream. This can continue as many times as needed, but must occur at least three times.

  • The output source code may be in a separate language.


Example

$ <program-1>
<program-2>

$ <program-2>
<program-3>

$ <program-3>
<empty>

Scoring

Each answer is scored by the following formula:

(length_in_bytes * number_of_distinct_characters) / number_of_distinct_programs 

For example, if your answer was 10 bytes long, contained 5 distinct characters, and output 3 distinct programs, your score would be:

(10 * 5) / 3

or 16.66.

Lowest score wins.


Note: This challenge was inspired by the comments on this StackOverflow question.

\$\endgroup\$
4
  • \$\begingroup\$ I suggest you add "lowest score wins" and remove anything above the TL;DR as per this meta answer \$\endgroup\$
    – agtoever
    Commented Jan 14, 2016 at 8:09
  • 5
    \$\begingroup\$ I'm voting to close as too broad because there is no criteria on what the programs should do, other than spitting out other programs. It would be trivial to create an infinite sequence of programs in stack-based languages with implicit output like Seriously. \$\endgroup\$
    – user45941
    Commented Jan 14, 2016 at 8:10
  • \$\begingroup\$ What's the score if you create infinite programs? 0? \$\endgroup\$
    – agtoever
    Commented Jan 14, 2016 at 8:11
  • \$\begingroup\$ For example: Q;+ will result in an infinite sequence of Seriously programs, each containing the previous program repeated twice. Score: 3*3/infinity \$\endgroup\$
    – user45941
    Commented Jan 14, 2016 at 8:15

2 Answers 2

3
\$\begingroup\$

Vitsy, 8 bytes, 8 distinct character, ∞ programs (score 0)

This is a simple proof in another stack-based language of Mego's comment.

'Drd3*Z1
' rd3*Z   Standard quine formula
 D     1  Increase the number of ones every output (output 1 will have 11,
          2: 111, 3: 1111, etc.)
\$\endgroup\$
3
\$\begingroup\$

Perl 5 - 34 bytes, 19 distinct characters, 10000000 programs (score 0.0000646)

$p="print q{$p}"for 1..1e7;print$p

The score can be lowered arbitrarily by increasing the constant 1e7, at the expense of taking longer and producing larger programs.

\$\endgroup\$

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