18
1
A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself... - until finally, the last one is empty. An example:
Today your goal is to emulate this Russian tradition by writing a program or function that, when it contains itself N times, will print itself containing N-1 copies of itself times.
For example, the doll program abcd
will have the N=3 program abababcdcdcd
, which will print the N=2 program ababcdcd
, which prints the original N=1 program abcd
, which finally prints N=0, which is empty. This should theoretically work for any reasonable value of N.
Rules:
- Here is a TIO program to help generate doll programs based on your program
- Standard Quine Rules apply
- Standard Loopholes apply
- 'Contains' means directly in the center of the previous version, so your solution must have a positive even number of bytes. A program of length 10 will have a copy of the original inserted after the fifth byte, then another after the tenth byte etc.
- A single trailing whitespace is allowed in the output
- As this is code-golf, your goal is to make your N=1 program as short as possible.
- An explanation of your code would be appreciated
Sandbox post (deleted) – Jo King – 2018-02-02T09:12:28.407
For what
N
is the code size measured? – flawr – 2018-02-02T09:52:33.993@flawr N=1..... – Jo King – 2018-02-02T10:06:43.223
N=0, which is empty
it HAS to be empty, or can be a single character? – Rod – 2018-02-02T10:49:52.893@Rod Has to be empty. 0 copies of a program is a blank string – Jo King – 2018-02-02T10:52:20.803
1Related: One More Program and I'm Out! – Kevin Cruijssen – 2018-02-02T11:15:25.853
12Is that animation really necessary?! – Shaggy – 2018-02-02T11:28:59.247