In this challenge, you will write a program which outputs a program which is the double the length of the original program. The outputted program should output a new program a program double its length.


If my program is a:

< a
> aa

< aa
> aaaa

< aaaa
> aaaaaaaa


  • No quine built-ins
  • The original program must be at least one byte
  • The sequence should theoretically work infinitely
  • Your program is not allowed to read from anything (file, stdio)

Your score is the size of the original program.

  • \$\begingroup\$ How about accessing the file by reading itself/accessing the place where the code is contained? \$\endgroup\$ – Conor O'Brien Jan 15 '16 at 23:36
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ that's not allowed as that would violate rules I believe. \$\endgroup\$ – Downgoat Jan 15 '16 at 23:37
  • 2
    \$\begingroup\$ @Doᴡɴɢᴏᴀᴛ the quine rules are recommended by the tag wiki but don't apply automatically \$\endgroup\$ – Martin Ender Jan 16 '16 at 0:27
  • 1
    \$\begingroup\$ Related: codegolf.stackexchange.com/questions/21831/… \$\endgroup\$ – PyRulez Jan 16 '16 at 1:35
  • 2
    \$\begingroup\$ Related. Related. Related. \$\endgroup\$ – Martin Ender Jan 16 '16 at 11:39

CJam, 10 bytes


Test it here.


{"_~" e# Generalised quine framework, leaves the block and the string "_~"
      e# on the stack. 
+     e# Prepend the block to the string.
_     e# Duplicate the resulting array.
|improve this answer|||||

JavaScript, 62 61 37 bytes

Thanks to @Doᴡɴɢᴏᴀᴛ for the help!

Original [37 bytes]:


Child [74 bytes]:


Grandchild [148 bytes]:


Alternate (with printing to console, and as a full program):

Original [61 bytes]:


Child [122 bytes]:


Grandchild [244 bytes]:


How it works!

1.   f=_=>   Define function f as console.log(...)

2.   ;f()   Run function f.

3.   (in function f)  

  • console.log(...)   Print the following:

    • f=   literal text "f="
    • ${'_'.repeat((0+f).length+5)   "_" repeated for the length of f, altered to account for characters not included in the stringification of f
    • +f}   The stringification of function f
    • ;f()   literal text ";f()"


  • console.log is necessary instead of alert because alert doesn't seem to play well with really long strings (at least on my machine/browser configuration)
  • The _'s are inserted into the name of the (unused) parameter of function f, to ensure that they are included in the stringification of f.
  • Main improvement (aside from getting rid of the console.log) of the first solution over the second: adding 10 to the function instead of 0 to cast it to string makes it one byte longer, eliminating the need to add 1 to the length afterwards, saving a byte.
|improve this answer|||||
  • \$\begingroup\$ 0+f should also work to cast the function to a string \$\endgroup\$ – Downgoat Jan 16 '16 at 1:41
  • \$\begingroup\$ 48 bytes: (f=_=>`(f=${'_'.repeat((0+f).length+5)+f})()`)() \$\endgroup\$ – Downgoat Jan 16 '16 at 2:29
  • \$\begingroup\$ @Doᴡɴɢᴏᴀᴛ Forgot that returning the result is usually acceptable. Will update. \$\endgroup\$ – jrich Jan 16 '16 at 2:51
  • \$\begingroup\$ @Doᴡɴɢᴏᴀᴛ Actually, since writing answers as functions is generally accepted, does the solution even have to call the function? \$\endgroup\$ – jrich Jan 16 '16 at 2:53
  • \$\begingroup\$ sure, you could do \$\endgroup\$ – Downgoat Jan 16 '16 at 2:55

Minkolang 0.15, 19 14 bytes


Original, child, grandchild.


"66*2-      $O.    Standard quine formulation

      r            Reverse stack
       I           Push length of stack
        D          Pop n and duplicate top of stack n times
         d         Duplicate top of stack
          r        Reverse stack

What the bit in between rs does is duplicate the ending period enough times to fulfill the doubling criterion. . is the "stop program" character, so the many periods at the end do nothing except be there.

|improve this answer|||||

CJam, 12 bytes


When run, this will print


which, in turn, will print


and so on.

Try it online!

|improve this answer|||||

Python 3, 51 bytes


This includes a trailing newline.

Which outputs:

|improve this answer|||||

GolfScript, 11 bytes

{: ".~"]}.~

Try it online!

How the source code works

{: ".~"]}.~

{       }    Define and push a code block.
         .~  Push a copy and execute it.
 :           Save the code block in the space character.
             Every subsequent space will now execute the code block.
   ".~"      Push that string.
       ]     Wrap the entire stack in an array.

If the above source code is executed once, the stack will end up as

["" {: ".~"]} ".~"]

where the empty string at the beginning corresponds to the initial state of the stack (empty input).

Two copies of the source code would leave a final state of

[["" {: ".~"]} ".~"] {: ".~"]} ".~"]

and so on.

What happens next

After executing the source code, the interpreter does the following:

  1. It wraps the entire stack in an array, and pushes that array on the stack.

    For a single copy of the source code, the stack now contains

    ["" {: ".~"]} ".~"] [["" {: ".~"]} ".~"]]
  2. It executed puts with the intention of printing the wrapped stack, followed by a linefeed.

    puts is defined as {print n print}, so it does the following.

    1. print prints the wrapped up copy of the stack without inspecting it (i.e., without converting it to its string representation). This sends

      {: ".~"]}.~

      to STDOUT and pops the stack copy from the top of the stack.

      The stack now contains

      ["" {: ".~"]} ".~"]
    2. executes the code block we defined previously.

      : begins by saving ["" {: ".~"]} ".~"] in the space character, then ".~" pushes itself and ] wraps the stack in an array.

    3. n pushes a string consisting of a single linefeed.

      The stack now contains

      [["" {: ".~"]} ".~"] ".~"] "\n"
    4. is executed once more. However, it was redefined when we called it for the first time and now contains an array, not a code block.

      In fact, it pushes ["" {: ".~"]} ".~"], leaving the stack as

      [["" {: ".~"]} ".~"] ".~"] "\n" ["" {: ".~"]} ".~"]
    5. Finally, print prints the topmost stack item without inspecting it, sending

      {: ".~"]}.~

      to STDOUT.

|improve this answer|||||

𝔼𝕊𝕄𝕚𝕟, 26 chars / 36 bytes


Try it here (Firefox only).

Note that there is a trailing newline.


Standard quine: ⟮ⒸⅩ222+ᶈ0


  • Use ô function to output the quines all results instead last result (as done using implicit output)
  • Use \u27ee⦃ᶈ0}\u27ef\n and close copy block to prevent conflicts with later copy blocks.
  • Use ď2 to repeat string twice.
|improve this answer|||||

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.