105
\$\begingroup\$

You are to write a program that will output source code that is

  1. Larger than the original program (character wise)
  2. Will print another program larger than itself when run (i.e. the new program is also a valid answer to this challenge)

This is code-golf, so shortest answer wins.

\$\endgroup\$
  • 4
    \$\begingroup\$ @Kevin, The definition is recursive. The output should be a program whose output is larger than itself, and an answer to this question. So the output's output should be larger than the output, and the output's output's output should be even larger, etc. \$\endgroup\$ – ugoren Feb 23 '14 at 10:55
  • 8
    \$\begingroup\$ I think you should clarify your rules. On one hand, any additional code output by such a program is "obviously useless"; on the other hand, all additional code in the output is "useful" in that it furthers the goal of answering this challenge. \$\endgroup\$ – Jason C Feb 23 '14 at 22:29
  • 5
    \$\begingroup\$ Sorry for destroying your challenge. :^) \$\endgroup\$ – Justin Feb 24 '14 at 5:03
  • 2
    \$\begingroup\$ I think this challenge would be much better as a popularity contest than a code golf. It would allow for a lot more creativity! \$\endgroup\$ – corsiKa Feb 24 '14 at 23:44
  • 27
    \$\begingroup\$ Naturally, such a program should be known as a quinine. \$\endgroup\$ – Jonathan Van Matre Feb 25 '14 at 5:05

40 Answers 40

1
\$\begingroup\$

Gol><>, 5 bytes

#H}"'

This, I believe, is the smallest growing quine possible in Gol><>. It duplicates the #H} over and over...

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Batch

set d=time  
copy c:\>loop.bat /B loop%d%.bat  
call c:\>loop.bat
\$\endgroup\$
0
\$\begingroup\$

Javascript - 46

(function $(){console.log('('+$+'());$()')}())
\$\endgroup\$
0
\$\begingroup\$

Pushy, 7 bytes

95&34_"

Non-competing as the language postdates the challenge. This outputs:

95 95 34
__"

which in turn outputs:

95 95 34
95 95 34
__"

and so on. After ~5 runs it looks like this:

95 95 34 95 95 34 95 95 34 95 95 34
95 95 34 95 95 34 95 95 34 95 95 34
__"__"__"__"
95 95 34 95 95 34 95 95 34 95 95 34
95 95 34 95 95 34 95 95 34 95 95 34
__"__"__"__"
\$\endgroup\$
0
\$\begingroup\$

Help, WarDoq!, 1 byte.

H

Prints Hello, World!.

Other characters than H are valid (and safe) source code (that print other variants of Hello World).

\$\endgroup\$
  • \$\begingroup\$ Also works in (variants of) HQ9+. \$\endgroup\$ – CalculatorFeline Jan 5 '17 at 2:39
  • \$\begingroup\$ @CalculatorFeline in HQ9+ this wouldn't continue to grow. \$\endgroup\$ – Martin Ender Apr 13 '17 at 9:18
0
\$\begingroup\$

k

41 bytes

f:{{(2*#x)#x}"f:",x,";`0:f@$f;"};`0:f@$f;

This program prints a copy of itself, and then doubles it. Thus it grows.

33 bytes

`0:{,//$("`0:";o;"[";x;"1];")}[1]

This program prints itself, but with an ever-growing number as the argument. This works in the closed-source interpreter.

\$\endgroup\$
0
\$\begingroup\$

Alice, 14 bytes

" <@o&h:2d+2..

Try it online!

Subsequent versions will have an increasing number of spaces after the ".

Explanation

" <@o&h:2d+2.."   Push the code points of the source code, except for the 
                  quotation marks.
<                 Send the IP back west.
"..2+d2:h&o@< "   Push the code points of the source code, except for the
                  quotation marks, in reverse.
..                Make two copies of the space. One will be the additional
                  space, one will be turned into the quotation mark.
2+                Add two, to turn 32 (space) into 34 (quote).
d                 Push the stack depth. This is about twice the number of characters
                  we want to print, because there's still the first copy of the source
                  on the stack. But it's two less than twice that number, because the
                  additional space and the quote aren't duplicated.
2:                Halve the value.
h                 Increment to account for the space and quote.
&                 Repeat the next command that many times.
o                 Print that many characters from the top of the stack.
@                 Terminate the program.
\$\endgroup\$
0
\$\begingroup\$

shortC, 99 bytes

i;ARa="i;ARa=%c%s%c,34,a,34,i+2);Oi=%d;i--;)",34,a,34,i+2);Oi=2;i--;)Ra="Ra=%c%s%c,34,a,34",34,a,34
\$\endgroup\$
0
\$\begingroup\$

Java 8, 92 bytes

v->{String s="v->{String s=%c%s%1$c+1;return s.format(s,34,s);}//";return s.format(s,34,s);}

Try it online.

Outputs (4 bytes larger):

v->{String s="v->{String s=%c%s%1$c+1;return s.format(s,34,s);}//"+1;return s.format(s,34,s);}//

Try first output program.

Which outputs (2 bytes larger):

v->{String s="v->{String s=%c%s%1$c+1;return s.format(s,34,s);}//1"+1;return s.format(s,34,s);}//1

Try second output program.

Which outputs (2 bytes larger):

v->{String s="v->{String s=%c%s%1$c+1;return s.format(s,34,s);}//11"+1;return s.format(s,34,s);}//11

Try third output program.

etc. (2 bytes larger every new program)

Explanation:

-part:

  • The String s contains the unformatted source code.
  • %s is used to input this String into itself with the s.format(...).
  • %c, %1$c and the 34 are used to format the double-quotes.
  • s.format(s,34,s) puts it all together

Challenge part:

  • Unformatted source code contains +1 and // to make the output program larger and compilable.
  • +1 adds a 1 to both the unformatted and formatted program.
\$\endgroup\$
0
\$\begingroup\$

Befunge-98 (FBBI), 38 bytes

::3a*3+-8jrfjj2,g0_0g,"+2",,1+:3d*`#@_

Try it online!

\$\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.