# Program that creates larger versions of itself (quine-variant)

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.

• @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. Feb 23, 2014 at 10:55
• 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. Feb 23, 2014 at 22:29
• Sorry for destroying your challenge. :^) Feb 24, 2014 at 5:03
• Naturally, such a program should be known as a quinine. Feb 25, 2014 at 5:05
• @facepalm42 Quine challenge answers are forbidden from reading their own source code, which makes comments tricky to use here. Nov 9, 2019 at 1:02

## BATCH, 26

Place this code in any .bat file and it will continue to execute (in an infinite loop) and the file will grow as well.

echo echo %0 ^>^> %0 >> %0

• This doesn't quite work, %0 is the command used to invoke the script, which may not have a .BAT extension. You can use %~nx0 to get the full filename of the batch file. Feb 24, 2014 at 0:06
• @JasonC AFAIK, it doesn't need the .bat to be executed. If the filename is execute.bat, you can enter either execute or execute.bat. Both will work. Feb 24, 2014 at 1:59
• The file itself needs to have a .bat extension to execute but you can leave the extension off when you execute it (when you type a command with no extension, Windows tries .com, .exe, then .bat in that order). If the filename is hello.bat, then >> %0 will write a file named hello, which isn't the original hello.bat (and can't be executed). Feb 24, 2014 at 2:40

## Batch

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


# PYG (6)

P(Q,Q)


Prints it's own source code, separated by newlines. The second generation would be

P(Q,Q)
P(Q,Q)


and so forth.

## OIL, 83 bytes

0
0
1
1
1
4
1
11
4
1
11
1
2
2
1
12
18
10
18
1
32
22
1
18
26
4
26
8
18
11
6
17
4
26


It first prints two lines with a zero in them, and then compares each line to line 1, if they're equal (which is the case when the file is exhausted), we print what's in cell 26. The resulting output will look the same, except with an added 33, which doesn't do anything. Next time, another line will be added, and so on.

# 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).

• Also works in (variants of) HQ9+. Jan 5, 2017 at 2:39
• @CalculatorFeline in HQ9+ this wouldn't continue to grow. Apr 13, 2017 at 9:18

# Charcoal, non-competing, 32 bytes

Ａ´α´´´Ａ´Ｆ´α´⁺´´´´´ι´αaα´ＡＦα⁺´´ια


Try it online!

Explanation:

first, go check out this answer on the quine challenge and its explanation.

This program is that program, but with the letter a at the end of the string variable.

Ａ                      α            Assign to a
´α´´´Ａ´Ｆ´α´⁺´´´´´ι´αa             "α´ＡＦα⁺´´ιαa", but with ´ escape character with each
character, except a
these are the variable being assigned to, and the
rest of the program that is not the string.

´Ａ         Print Ａ to the grid. current grid: "Ａ"
Ｆα⁺´´ι  For each character in a, print ´ + character
this results in the escaped version of the string
which is the literal string that is assigned at the
start, plus a escaped. current grid state: "Ａ´α´´´Ａ´Ｆ´α´⁺´´´´´ι´α´a"

α Print a ("α´ＡＦα⁺´´ιαa"), which is the commands after
the string assignment. final grid state vvv:
"Ａ´α´´´Ａ´Ｆ´α´⁺´´´´´ι´α´aα´ＡＦα⁺´´ιαa"

[implicitly print the grid: "Ａ´α´´´Ａ´Ｆ´α´⁺´´´´´ι´α´aα´ＡＦα⁺´´ιαa", the new program]


This new program works in the same way, except for two things:

• the "a" is escaped (which has no effect, as "a" escaped is "a")

• there is an "a" at the end of the program. this "a" will write an extra "a" after the source is produced. thus the program grows slowly

# C, 116149197 189 bytes

i;main(a){printf(a="i;main(a){printf(a=%c%s%1$c,34,a,i+2);for(i=%d;i--;)",34,a,i+2);for(i=1;i--;)printf(a="printf(a=%c%s%1$c,34,a,34),",34,a);printf(a="0;printf(a=%c%s%1$c,34,a);}",34,a);}  ### How it works • main(a){ declares the main function with an untyped variable a. • The first printf prints the existing source code and a for loop. An integer is printf'd into the for loop. This is how the multi-quine works - each time the quine program is called, it increments d, making the for loop run more times. • The second printf is inside the for loop and prints itself, so each time the quine program is called, there are more printf's, therefore generating bigger versions of itself. Be warned that this growth is exponential, due to the for loop incrementation and the multiple printfs. • The third printf prints the remaining source code. Requires POSIX. # 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! # AsciiDots, 20 bytes ($'#a_$93#"$_@("_$-.  Try it online! ### First run Sends a dot leftward, printing the characters (@_$ with a literal and ' from the ASCII value 39. The dot then turns around and interprets the path as a string, printing the rest of the line.

(@_$'#a_$93#"$_@("_$-.

Prints (@_$' again, as well as a 0, thanks to the added @_ from the first run. The 0 ends up on the right side of the ' symbol, which means that all 0s printed in a previous run carry over. The dot safely ignores the additional 0s on its path. (@_$'0#a_$93#"$_@("_$-. (@_$'00#a_$93#"$_@("_$-. (@_$'000#a_$93#"$_@("_$-. # Bash, 14 bytes cat$0&cat $0&  Try it online! # Keg, 18151413SBCS1110SBCS9SBCS 6SBCS bytes ④⑩④⑩  Try it online! I've gone and done it now! No more ascii around here now folks. This will print: ④⑩④⑩④⑩  Which will print: ④⑩④⑩④⑩④⑩④⑩  Which prints: ④⑩④⑩④⑩④⑩④⑩④⑩④⑩④⑩  And so on. ## Answer History ### 9 bytes ::.,⑵④⑩  This uses the same approach as the 10 byte answer Explained ::.,⑵④⑩ ::., #Push the string ::., ⑵ #Double the string ④⑩ #Print raw then nice without popping  ### 10 bytes ::.,⑵:.,  This prints: ::.,::.,::.,::.,  Which prints: ::.,::.,::.,::.,::.,::.,::.,::.,  ### 11 bytes ::.,6*:.,  This prints: ::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,  Which prints: ::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,::.,  And so on Try it online! ### 13 bytes ::.,!⑨*:(.,  Try it online! This prints: ::.,::.,::.,::.,  Which prints: ::.,::.,::.,::.,::.,::.,::.,::.,  And so on. ### 14 bytes ::.,(:.,):.,  Try it online! This will create pretty much the same chain as the previous 15-byter. ### 15 bytes ::.,(::.,):.,  This prints: ::.,(::.,)::.,(::.,)  Which prints: ::.,(::.,)::.,(::.,)::.,(::.,)::.,(::.,)  And so on. Try it online! ### 18 bytes :::.,(!2/|.,):.,  Try it online! This will print :::.,(!2/|.,):::.,(!2/|.,)  Which in turn prints: :::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,)  Which then prints: :::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,):::.,(!2/|.,)  And so on. Try it online! # Japt, 12 bytes "iQ ²Ä"iQ ²Ä  Try it online! Based off the Standard Japt quine ## Explanation For first iteration "iQ ²Ä" // Take this string. iQ ²Ä iQ // Insert a quote. "iQ ²Ä ² // Double. "iQ ²Ä"iQ ²Ä Ä // Concatenate 1 to end "iQ ²Ä"iQ ²Ä1 // Implicitly output.  On Each iteration it will concatenate another 1 to the end of the program # JavaScript (ES6/2015), 12 bytes a=_=>'a=_'+a  Try it online! ## with invokation, 23 bytes (a=_=>'(a=_'+a+')()')()  Try it online! Every iteration adds an underscore to the parameter name # Wolfram Language (Mathematica), 19 bytes ToString[10#0][]&[]  Try it online! Returns 10 (ToString[10 #0][] & )[], which, when run, returns 10*10 (ToString[2 #0][] & )[]. From there, the beginning number is multiplied by 10 at every step, which increases the length of the code by 1. # Julia 1.0, 33 bytes a=[show,print] ".|>$([a;a])
".|>a


Try it online!

prints (79 bytes):

".|>Function[show, print, show, print]\n".|>Function[show, print, show, print]


then, the program is doubled each time:

".|>Function[show, print, show, print]\n".|>Function[show, print, show, print]
".|>Function[show, print, show, print]\n".|>Function[show, print, show, print]


based on this quine:

".|>[show,print]".|>[show,print]


Try it online!

Javascript - 46

(function $(){console.log('('+$+'());$()')}())  # 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 __"__"__"__"  # 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.

## 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.


# 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


# 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. # Befunge-98 (FBBI), 38 bytes ::3a*3+-8jrfjj2,g0_0g,"+2",,1+:3d*#@_  Try it online! Python 3, 54 chars print((lambda s:s%s)('print((lambda s:s%%s)(%r)*2);')) I simply modified this quine. You can try it simply doing python this.py | python | python ... | python many times. Edit: found this problem on the homepage and discovered too late that it is old. • There's no issue solving old challenges. Jul 16, 2019 at 0:39 # C (gcc), 132 bytes It's not often you get to recycle answers from other questions. x;*s="x;*s=%c%s%c;main(i){for(i=__LINE__;i--;puts(&x));printf(s,34,s,34);}";main(i){for(i=__LINE__;i--;puts(&x));printf(s,34,s,34);}  Try it online! # Haskell, 155 bytes g=putStrLn("n=1"++show n++('-'<$[1..n]));main=(\s->putStr s>>print s>>g)$"g=putStrLn(\"n=1\"++show n++('-'<$[1..n]));main=(\\s->putStr s>>print s>>g)\$"
n=2


Try it online!

## W, 15 bytes

A proper quine, except it grows very oddly.

pp34CS+"pp34CS+


Iterations (You can see that the output gets between and after the source code... ):

pp34CS+pp34CS+"pp34CS+
pp34CS+pp34CS+pp34CS+pp34CS+"pp34CS+pp34CS+


# C (gcc), 71 bytes

#define a(b)*s=#b;b
a(main(){printf("#define a(b)*s=#b;b\na(%s;)",s);})


Every iteration adds a semicolon after the closing brace of the main function.

Try it online!

# Lua, 58 bytes

f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))


Attempt This Online! Repeats the formatted string 9 times. This is the result of iteration 1:

f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))f="f=%qprint(f:format(f):rep(9))"print(f:format(f):rep(9))


# DipDup, 12 bytes

[[_^!]:_:]_:


Try it online!

The TIO link is the DipDup interpreter written in Haskell.

Based on my DipDup quine: [_:]_:. [_^!]: converts a block [abc] to [[abc]_^!], which is equivalent to [abc] but longer.

This outputs [[_^!]:_:][_^!]:_:. After that, [abc]abc becomes [[abc]_^!][abc]_^! in each step.

# Python 2, 31 bytes

s='s=%r;print s%%s*2;';exec s%s


Try it online!

the next iterations are:

s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
# ------------------------------------
s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
# -------------------------------------
s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
s='s=%r;print s%%s*2;';print s%s*2;s='s=%r;print s%%s*2;';print s%s*2;
# ------------
...


# Python 3, 33 bytes

a='a=%r;print(a%%a*2);';exec(a%a)


Try it online!

a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
# ------------------------------------
a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
# -------------------------------------
a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
a='a=%r;print(a%%a*2);';print(a%a*2);a='a=%r;print(a%%a*2);';print(a%a*2);
# ------------
...
`