g | x | w | all
Bytes Lang Time Link
027Ruby140223T163542Zdaniero
3327JavaScript230127T111821ZEzioMerc
014><> Fish230104T093006Zmousetai
001Batch221220T062937Zl4m2
031Python 2211007T080515ZJakque
012DipDup220505T074348Zalephalp
033Julia 1.0220504T085310ZMarcMush
019Wolfram Language Mathematica220503T171321ZRomanp
006Microscript II161112T011948ZSuperJed
058Lua220323T211915Ztwentysi
071C gcc211007T222622ZPetr Fie
012JavaScript ES6/2015211006T124621ZPetr Fie
011Husk201006T073459ZJo King
004Jelly201006T042359ZUnrelate
012Japt200630T090416ZMukundan
034Python 2200118T113543ZMukundan
015W191127T142153Zuser8505
006Keg191108T060745Zlyxal
014Bash190906T060030Zmekb
9981Evoloop190906T022834ZSophie S
155Haskell190811T010450ZB. Mehta
009Underload190729T201225ZEdgex42
132C gcc190716T065459Zgastropn
054Python 3190715T001126ZAndrea C
020AsciiDots190714T202620ZAlion
006Runic Enchantments190214T034353ZDraco18s
005Gol><>190210T224357ZKrystosT
038Befunge98 FBBI181228T121416ZWisław
001J180907T055027ZBubbler
000GS2 8636bd8e161017T215448ZDennis
092Java 8180320T162844ZKevin Cr
189C170525T014832ZMD XF
099shortC170525T173350ZMD XF
032Charcoal170520T003306ZDestruct
014Alice170413T185103ZMartin E
nan170413T161611Zzgrep
001Help161216T212355Zn4melyh4
007Pushy161216T210711ZFlipTack
083OIL161115T084724ZL3viatha
040JavaScript140225T011819ZDocMax
01505AB1E161111T062552ZOliver N
011reticular161018T002720ZConor O&
011dc140223T200319Zdaniero
066Julia150630T004133ZM L
001H9+140223T053511ZJustin
006PYG140422T171952Zɐɔıʇǝɥʇu
nan140323T165225ZThomas B
046Javascript140226T143918Zˈvɔlə
016Common Lisp140226T022007ZStuart O
038ECMAScript 6 38 Characters140225T004129ZMT0
nan140224T164935ZDaniel
029Lambda Calculus140224T160233Zdaniel g
007SH script140224T005008ZJens Era
057Smalltalk140223T123409Zblabla99
000Java 7140223T175943ZJustin
009SH script140223T224501ZJason C
025Windows .BAT140224T000218ZJason C
026BATCH140223T234445ZSameOldN
055Python 3140223T202854Zuser1547
038PHP140223T154912ZComFreek
009GolfScript140223T140018ZIlmari K
051EcmaScript 6140223T102826ZToothbru
002HQ9+140223T024844ZVictor S

Ruby 27

A very slightly modified version of this (via):

puts <<3*3,3
puts <<3*3,3
3

The number of times that puts-line is printed grows exponentially.

$ ruby quine.rb | ruby | ruby
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
3

$ ruby quine.rb | ruby | ruby | ruby | ruby | ruby | ruby | ruby | wc -l
    3283
    

JavaScript, 33 bytes (27 if alert)

f=_=>console.log(`f=${f};f(f())`)

Try it:

console.log('First execution');

f=_=>console.log(`f=${f};f(f())`)

f();

console.log('After prev execution');

f=_=>console.log(`f=${f};f(f())`);f(f())

console.log('After prev execution');

f=_=>console.log(`f=${f};f(f())`);f(f())
f=_=>console.log(`f=${f};f(f())`);f(f())

console.log('After prev execution');

f=_=>console.log(`f=${f};f(f())`);f(f())
f=_=>console.log(`f=${f};f(f())`);f(f())
f=_=>console.log(`f=${f};f(f())`);f(f())
f=_=>console.log(`f=${f};f(f())`);f(f())

//...

><> (Fish), 14 bytes

'rd3*9[r:r]>o<

Try it

First iteration duplicates the : in the middle: (it actually duplicates itself):

'rd3*9[r::r]>o<

Then since there are now 2 duplication signs it will duplicate itself twice:

'rd3*9[r::::r]>o<

etc. doubling each time.

><> (Fish), 9 bytes (Boring version)

':rd3*>o<

Try it

This simply duplicates the < at the end:

':rd3*>o<<
':rd3*>o<<<

etc. So the functionality of the program won't be effected at all. It's basically a comment.

Batch, 1 byte

a

Add prompt at head every time, error is who cares

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

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.

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!

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.

Microscript II, 6 bytes

"qp"qp

The first iteration adds an extra qp to the end, and each successive iteration adds an extra copy of this original program to the beginning.

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

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!

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

Husk, 15 11 bytes

-4 bytes thanks to Unrelated String

S+s"So+uswg

Try it online!

Outputs So+uswg"So+uswg" then S o+uswg"S o + u s w g" then S o+uswg"S o + u s w g"... This is a variant of the usual quine S+s"S+s" but with increasing spaces between each character in the string. Currently there's a bug in the parser that prevents double spaces in the code itself, otherwise this could forgo the unique stripping out spaces in the code section and could be 9 bytes.

Jelly, 4 bytes

⁾ṘȮv

Try it online!

Originally written for a CMC in JHT.

⁾ṘȮ     "ṘȮ"
   v    evaluated with the argument
⁾ṘȮ     "ṘȮ".

 Ṙ      Print a Jelly string representation of the argument,
  Ȯ     print the argument,
        then implicitly print it again.

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

Python 2, 38 37 36 34 bytes

-1 bytes thanks to Jo King

s='print"s=%r;exec s;"%s+s';exec s

Try it online!


Python 3.8 (pre-release), 39 38 36 bytes

exec(s:='print("exec(s:=%r);"%s+s)')

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+

Keg, 18 15 14 13SBCS 11 10SBCS 9SBCS 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!

Bash, 14 bytes

cat $0&cat $0&

Try it online!

Evoloop, 9×9 rectangle (81 cells)

The Evoloop cellular automaton included with Golly supports patterns which replicate themselves in a "quine-like" way. Specifically, these patterns each contain a "program"; a pattern reproduces itself by first executing the program (which creates the "body" of the daughter), and then by copying the program into the daughter.

The above applies to the more famous "Langton's Loops" cellular automaton as well as Evoloop, but Evoloop has an interesting difference, which is that it's easy to create a pattern which grows in each successive generation.

(Much more interesting, in my opinion, is the fact that Evoloop is a simple cellular automaton which contains patterns which reproduce themselves and evolve in a very life-like manner! I think the only known cellular automata which do this are Evoloop and its descendants. A shortcoming of Evoloop, however, is that there is one particular "best" genome; evolution always eventually converges to this one genome.)

Now, there are two shortcomings to this submission. One is that it's not clear what the "output" of a cellular automaton is. But I think that a self-reproducing automaton is "close enough" to being a quine; it's certainly no less interesting! The other shortcoming is that these patterns don't merely create a single copy of themselves; each copy of the original pattern attempts to create infinitely many copies of itself, and these copies end up interacting with each other in a destructive manner. So, I think I've met the requirements of this challenge in spirit, but not in letter.

Without further ado, the pattern is:

022222220
270170172
212222202
202000212
272000272
212000202
202222212
271041032
022222250

Here's the pattern again, in a format that can be copied and pasted into Golly:

x = 9, y = 9, rule = Evoloop
.7B$BG.AG.AGB$BA5B.B$B.B3.BAB$BGB3.BGB$BAB3.B.B$B.5BAB$BGA.DA.CB$.6BE
!

Okay, but what does it look like? It looks like this:

A pattern in a cellular automaton which creates increasingly large copies of itself.

In the above animation, you can see the initial pattern create a larger daughter, which creates a larger granddaughter, then a larger great-granddaughter, and finally an even larger great-great-granddaughter which starts to construct a yet larger third-great-granddaughter. If you ran this pattern for a long time, it would keep going on like this forever (or perhaps they would eventually be overtaken by the evolved organisms, which are capable of reproducing much faster; I'm not sure).

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!

Underload, 9 bytes

(:::aSSS):^

Modification on the standard underload quine, which is (:aSS):aSS. First, I changed the second :aSS into :^ since it still runs the same code (by duplicating and then running the top item of the stack, which is the stuff inside the bracket) whilst saving bytes. Then I added another S to make it so the program gets longer, and added two more :s to make it so the program it produces doesn't error.

Try it Online!

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!

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.

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#"$_@("_$-.


Subsequent runs

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#"$_@("_$-.

Runic Enchantments, 6 bytes

"'<S@>

Try it online!

This one was weird. All I had to do was remove a ~ from the original quine found by Jo King.

Every additional run appends another < to the end, e.g.:

"'<S@><<<<<<<<<

All of which do nothing.

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!

Befunge-98 (FBBI), 38 bytes

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

Try it online!

J, 1 byte

'

Try it online!

The open quote gives, obviously, the open quote error:

|open quote
|   '
|   ^
|[-1] /home/runner/.code.tio

Note that, by the nature of J interpreter, the errors are printed to STDOUT, not STDERR.

When the above is run as code, it prints:

|open quote
|   |   '
|       ^
|[-2] /home/runner/.code.tio

Then

|open quote
|   |   |   '
|           ^
|[-2] /home/runner/.code.tio

and so on. Each time the code runs, the second line is left-padded with four bytes |   , fulfilling the requirement of this challenge.

J, proper quine variant, 25 bytes

echo,~'echo,:~(,quote)'''

Try it online!

Outputs

echo,:~(,quote)'echo,:~(,quote)'

And then it outputs itself twice, on separate lines:

echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'

then

echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'

and so on.

The first output is a simple variant of standard J quine. The added ,:~ concatenates itself vertically, where the resulting 2D array is printed as two rows of the same string.

GS2 (8636bd8e), 0 bytes



This prints a single newline, which prints two newlines, which prints three newlines, et cetera.

Try it online!

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:

Challenge part:

C, 116 149 197 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

Requires POSIX.

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

Charcoal, non-competing, 32 bytes

A´α´´´A´F´α´⁺´´´´´ι´αaα´AFα⁺´´ια

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.

A                      α            Assign to a
 ´α´´´A´F´α´⁺´´´´´ι´αa             "α´AFα⁺´´ια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.

                         ´A         Print A to the grid. current grid: "A"
                            Fα⁺´´ι  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´α´´´A´F´α´⁺´´´´´ι´α´a"

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

[implicitly print the grid: "A´α´´´A´F´α´⁺´´´´´ι´α´aα´AFα⁺´´ιαa", the new program]

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

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.

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.

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

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
__"__"__"__"

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.

JavaScript, 41, 40 chars

function f(){console.log(f+"f(f())")}f()

The first time you run it it outputs itself with another ;f() at the end. Subsequent runs of the output results in each "input" source printed twice.

alert would be shorter than console.log but I don't consider multiple alert dialogs to be "the" output while it seems reasonable to call multiple lines in the console as an output.

05AB1E, 15 bytes, noncompeting

0"DÐ34çý"DÐ34çý

Try it online!

Prints 0"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý,
which prints 0"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý,
etc.

reticular, 11 bytes, noncompeting

"'34'coo1o;

This is the standard quine framework, except an extra 1 is printed after each iteration. Try it online!

First few outputs:

"'34'coo1o;
"'34'coo1o;1
"'34'coo1o;11
"'34'coo1o;111

dc 11

Quite simple:

6579792
dfP

The first line is repeated once every generation:

$ dc growing_quine.dc
6579792
6579792
dfP

$ dc growing_quine.dc | dc | dc 
6579792
6579792
6579792
6579792
dfP

The last line consists of the following instructions: d duplicates the last value put on the stack (6579792) (so that we get one more copy each time we run it), f prints the whole stack (which is a bunch of that same number) and P prints the number (6579792) out as a byte stream, which displays as dfP.

Julia, 66 chars

x="print(\"x=\$(repr(x))\\n\$x;\"^2)";print("x=$(repr(x))\n$x;"^2)

Output (134 chars):

x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);

Result of executing the result (268 chars):

x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);

next result (536 chars):

x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);

Next result (1072 chars):

x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);

I hope this is according to the rules.

It produces larger output, and the output itself is valid source code that produces larger output again.

H9+ : 1 char

9

That's right. One character. Outputs the lyrics to 99 bottles of beer, which is a valid program. All the extraneous data does not count, but there are plenty of 9s in there.

The output of the outputted program is the lyrics to 99 bottles of beer 59 times.

This function gives the number of times the lyrics are outputted if you run the program n times (if my calculation is correct):

f(n) = 59n-1

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.

redcode (recursive solution)

This is the code of the easiest warrior writable in redcode, the famous Imp:

MOV 0, 1

When executed, the code writes a copy of its single instruction at the next address in memory; then executes it, etc.

Javascript - 46

(function $(){console.log('('+$+'());$()')}())

Common Lisp, 16 Characters

(print `(or ,-))

Granted, it's interactive-only, but being able to reference the current top-level form is probably the single best way to minimize a non-trivial program that meets the specification.

What would be really interesting is what blows up the fastest. Maybe something like

(print `(progn ,@(loop repeat (length -) collect -)))

ECMAScript 6 (38 Characters)

(f=_=>'(f='+f+')();(f='+f+')();')();

Which outputs:

(f=_=>'(f='+f+')();(f='+f+')();')();(f=_=>'(f='+f+')();(f='+f+')();')();

Edit

You could do (28 characters):

(f=_=>'(f='+f+')();'+f())();

However it will recurse infinitely and never return anything... but this can be solved by doing something like this (42 characters):

(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(3);

Which will output:

(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(3);(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(2);(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(1);

Batch

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

Lambda Calculus - 29

A simple lambda term

(λu.(u u)(u u))(λu.(u u)(u u))

Reducing this term by one beta reduction yields

((λu.(u u)(u u))(λu.(u u)(u u)))((λu.(u u)(u u))(λu.(u u)(u u)))

And so on and so on. It's a simple variant on the classic (λu.u u)(λu.u u) which is a quine in lambda calculus, double self application here means we get twice the output.

SH script, 12 8 7

Store a file with

sed p *

in its own, empty directory and run from this directory using sh [file] or set executable.


Old alternative with 8 characters, but doesn't need its own directory. Store a file with

sed p $0

and run using sh [file] or set executable.

Old alternative with 12 characters:

sed -i- p $0

This will actually output to the program file itself, but where to output was not specified. Replicates itself at an exponential rate.

Smalltalk, 125 61 57

The golf version looks almost unreadable so I'll explain first (and use real identifiers).

This is a variant of the "weirdest-way-to-produce-a-stack-overflow" self modifying method.

The method prints out a hello message, and its current source (for the demonstration only). Then, the code is modified to output a longer string and installed. Finally, the new code is called recursively.

In order to protect myself from an immediate runaway, it lets the user confirm in each cycle.

compile in Object:

eatMe_alice
   |msg mySource|

   mySource := thisContext method source.

   '**** Hello Alice' printCR.
   '  ---- my current code is:' printCR.
   mySource printCR.
   '  ---------------' printCR.

   (UserConfirmation confirm:'Again? ') ifTrue:[
       Object compile:
            (mySource
                copyReplaceString:'Hello ','Alice'
                withString:'Hello ','Alice !').
       self eatMe_alice
   ]

start the show by sending "eatMe_alice" to any Object; nil will do:

nil eatMe_alice

A nice variant is to not call the new code recursively, but instead iteratively, by unwindig the call stack and reentering into the new method. This has the advantage of not leading to a recursion exception. To do this, replace the recursive call ("self eatMe_alice") by:

thisContext resend

Golfing:

Obviously, printing and self calling was not asked for, so the shortest (for golf) is to simply append a comment to my own source and return it. As a side effect, it also gets installed for the next call...

x|s|Object compile:(s:=thisContext method source,'""').^s

Java 7: 0 chars


Save as file Blank.java. If you save it as any other file, replace any instance of Blank with the appropriate file name.

Then, run in command line via first compiling, then running. If compiling fails, stop.

I list this as Java 7 because it might output differently for different versions of Java.

First few outputs (outputted to stderr):

Error: Could not find or load main class Blank
Blank.java:1: error: class, interface, or enum expected
Error: Could not find or load main class Blank
^
Blank.java:1: error: reached end of file while parsing
Error: Could not find or load main class Blank
                                              ^
2 errors
Blank.java:1: error: class, interface, or enum expected
Blank.java:1: error: class, interface, or enum expected
^
Blank.java:1: error:  expected
Blank.java:1: error: class, interface, or enum expected
                          ^
Blank.java:1: error:  expected
Blank.java:1: error: class, interface, or enum expected
                                     ^
Blank.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Blank.java:1: error: class, interface, or enum expected
                                          ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Blank.java:1: error: = expected
Blank.java:1: error: class, interface, or enum expected
                                               ^
Blank.java:2: error:  expected
Error: Could not find or load main class Blank
     ^
Blank.java:2: error: ';' expected
Error: Could not find or load main class Blank
      ^
Blank.java:2: error: = expected
Error: Could not find or load main class Blank
                      ^
Blank.java:2: error: = expected
Error: Could not find or load main class Blank
                                   ^
Blank.java:2: error:  expected
Error: Could not find or load main class Blank
                                              ^
Blank.java:3: error: = expected
^
^
Blank.java:3: error: ';' expected
^
 ^
Blank.java:4: error: illegal start of type
Blank.java:1: error: reached end of file while parsing
     ^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
          ^
Blank.java:4: error: illegal start of type
Blank.java:1: error: reached end of file while parsing
           ^
Blank.java:4: error:  expected
Blank.java:1: error: reached end of file while parsing
            ^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
          ^
Blank.java:4: error: illegal start of type
Blank.java:1: error: reached end of file while parsing
           ^
Blank.java:4: error:  expected
Blank.java:1: error: reached end of file while parsing
            ^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
              ^
Blank.java:4: error: ';' expected
Blank.java:1: error: reached end of file while parsing
                   ^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
                                 ^
Blank.java:4: error:  expected
Blank.java:1: error: reached end of file while parsing
                                        ^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
                                         ^
Blank.java:4: error: ';' expected
Blank.java:1: error: reached end of file while parsing
                                              ^
Blank.java:5: error:  expected
Error: Could not find or load main class Blank
     ^
Blank.java:5: error: ';' expected
Error: Could not find or load main class Blank
      ^
Blank.java:5: error: = expected
Error: Could not find or load main class Blank
                      ^
Blank.java:5: error: = expected
Error: Could not find or load main class Blank
                                   ^
Blank.java:5: error:  expected
Error: Could not find or load main class Blank
                                              ^
Blank.java:6: error: = expected
                                              ^
                                              ^
Blank.java:6: error: ';' expected
                                              ^
                                               ^
Blank.java:7: error: reached end of file while parsing
2 errors
        ^
30 errors

SH script, 9

cat $0 $0

Grows at exponential rate.

Either run as sh whatever.sh or set it as executable.

Windows version is here.

Windows .BAT, 25

@COPY %~nx0+%~nx0 CON>NUL

Grows at exponential rate.

Equivalent SH version here.

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

Python 3 - 55

print(open(__file__).read())
f=lambda:print('f()')
f()

This could be made shorter by replacing __ file__ with a single character filename and saving the file as that, but I felt this answer was more in the spirit of the question. After one iteration it outputs:

print(open(__file__).read())
f=lambda:print('f()')
f()
f()

PHP, 38

<?echo fgets(fopen(__FILE__,'r')).';';

It will add a semicolon at each run.

GolfScript, 9 chars

{.'.~'}.~

This code outputs:

{.'.~'}{.'.~'}.~

which outputs:

{.'.~'}{.'.~'}{.'.~'}.~

which outputs:

{.'.~'}{.'.~'}{.'.~'}{.'.~'}.~

and so on.

I believe this is the shortest answer in a "real" Turing-complete programming language so far.

Explanation:

Basically, the original code above is a "quine-layer": it outputs a normal quine followed by itself.

In GolfScript, any code block literal (e.g. {foo}), if left undisturbed on the stack, is a quine. Thus, on its own, {.'.~'} simply outputs itself, just like any other code block would.

The .~ at the end of the code takes the last code block on the stack, duplicates it, and executes the copy. When executed, the code .'.~' inside the code block duplicates the topmost item on the stack (i.e. the copy of itself) and appends the string .~.

At the end of the program, the GolfScript interpreter stringifies and outputs everything on the stack, which, in this case, consists of one more {.'.~'} block than in the input, plus the string .~.

Bonus:

Adding a ] before the first . (to collect all the code blocks on the stack into an array before they're duplicated) makes it grow exponentially:

{].'.~'}.~

outputs:

{].'.~'}{].'.~'}.~

which outputs:

{].'.~'}{].'.~'}{].'.~'}{].'.~'}.~

which outputs:

{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}.~

and so on.

EcmaScript 6 (51 bytes):

(_=x=>'(_='+_+Array(x++).join(','+_)+')('+x+')')(2)

It produces a longer version of itself, which can produce a longer version of itself, which can produce a longer version of itself, etc. ...

HQ9+, HQ9++ and similars, 2 characters

QQ

This is the output:

QQQQ