Create a kind of quine, such that the program prints one character of itself, then two, then three and so on

Create quine variant such that the program prints its first character, then the first two, then three and so on until the whole program is printed.

Example

Suppose your code is @@@@@2 in some language. Then the output should be

@
@@
@@@
@@@@
@@@@@
@@@@@2


in that order, each line separated by a newline.

The winner is the shortest quine like this.

• What's the winning criteria? – user202729 Nov 24 at 14:39
• Whoops, sorry. If nobody submits a quine in 1 week from the last submission, the last submitter wins. – Andrew Nov 24 at 14:44
• Isn't that essentially the same as "no winning criteria"? ... (or "your score is 1. The lowest score wins." etc.) – user202729 Nov 24 at 15:20
• (we do have some previous challenges like this, the pop-con ones and some answer-chaining ones where the latter answer isn't dependent on the former, but not everyone think that's ok.) See also meta post. – user202729 Nov 24 at 15:22
• Hello, welcome to the site! I think the core of this challenge is interesting, but the win condition makes it kind of pointless. There's nothing that any one could do to improve the chances of winning. With code-golf, you can always improve your program and your score. – DJMcMayhem Nov 24 at 15:46

Jelly, 10 bytes

“;⁾vṾÄY”vṾ


Try it online!

How it works

“;⁾vṾÄY”vṾ  Main link. No arguments.

“;⁾vṾÄY”    Set the return value to the string ';⁾vṾÄY'.
Ṿ  Uneval; yield a string representation of the string, i.e., '“;⁾vṾÄY”'.
v   Dyadic eval; execute the string to the left, passing the string to the
right as argument.
⁾vṾ         Literal; yield 'vṾ'.
;            Concatenate the argument ('“;⁾vṾÄY”') and 'vṾ', yielding '“;⁾vṾÄY”vṾ'.
Ä        Accumulate; take the cumulative sum.
Since string addition is concatenation in Python (and Jelly doesn't do
type checks), this yields all prefixes of the string.
Y       Join the prefixes, separated by linefeeds.


Husk, 18 bytes

G:""S+s"G:\"\"S+s"


Try it online!

Explanation

An extension of the standard quine S+s"S+s". To get all the prefixes we cannot use ḣ (heads), because ḣS+s"ḣS+s" would show "ḣS+s" which results in "\7715S+s":

ḣS+s"ḣS+s"


Try it online!

So we need to re-implement heads without using any unicode, this can be done by scanl snoc "" (snoc is just a flippped version of (:)), ie. G:"" which is ASCII.

Oracle SQL, 154 bytes

select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;


Test in SQL Plus

SQL> set lines 160 pages 0
SQL> select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;
s
se
sel
sele
selec
select
select
select s
select su
select sub
select subs
select subst
select substr
select substr(
select substr(r
select substr(rp
select substr(rpa
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by l
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by le
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by lev
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by leve
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<1
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<15
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;s
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;se
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;sel
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;sele
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;selec
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select s
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select su
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select sub
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select subs
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select subst
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(r
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rp
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpa

154 rows selected.


-2 bytes thanks to Dennis

main=mapM g[1..98];g n=putStrLn$take n$id<>show$"main=mapM g[1..98];g n=putStrLn$take n$id<>show$"


Try it online!

Surprisingly 2 4 bytes shorter than the obvious port of my Husk answer:

main=mapM putStrLn$scanl((.pure).(++))[]$id<>show$"main=mapM putStrLn$scanl((.pure).(++))[]$id<>show$"

JavaScript, 47 bytes

This can probably be improved.

Revisions

20 bytes have been saved so far between 3 versions!

Revision 5

There's been a lot of bytes saved with this revision:

• Don't assign a single-use variable for the quine to save 2 bytes
• Use templated strings for the quine to save a byte
• Use a single parameter (_) instead of no parameters (()) to save a byte

These three changes get it down to 47 bytes!!

(s=_=>{for(c of (s=${s})())alert(name+=c)})()  Revision 4 On most pages, it seems that window.name is an empty string by default. We can take advantage of this to get 53 bytes! (s=()=>{q="(s="+s+")()";for(c of q)alert(name+=c)})()  Unfortunately this is not the case for the snippet page, but try running it with the developer tools! Revision 3 We can save 2 bytes, down to 55 bytes, by combining the two statements in the loop into one: (s=()=>{q="(s="+s+")()",h="";for(c of q)alert(h+=c)})() Revision 2 We can get down to 57 bytes by using an EcmaScript 2015 arrow function: (s=()=>{q="(s="+s+")()",h="";for(c of q)h+=c,alert(h)})() Revision 1 We can also get down to 61 bytes by using alert instead of console.log, if you consider that to be printing: (function s(){q="("+s+")()",h="";for(c of q)h+=c,alert(h)})() Initial Version Initially, this script was at 67 bytes: (function s(){q="("+s+")()",h="";for(c of q)h+=c,console.log(h)})() Explanation Here's the prettified code: (function func() { quine = "(" + func + ")();"; substr = ""; for (char of quine) { substr += char; console.log(substr); } })(); We start with a standard quine, then we define substr. We loop over each character of the quine, add it to substr, then output that. • uhhh... it doesn't really work. no chance of qualifying. – Andrew Nov 24 at 17:08 • Try now. I accidentally sent it before I was done. – haykam Nov 24 at 17:08 • good one, it qualifies now – Andrew Nov 24 at 17:09 • I accidentally clicked run code snippet on the alert version... add a warning to that plz :P – Quintec Nov 24 at 20:03 Jelly, 14 bytes “Ṿ;¹¹ƤY”Ṿ;¹¹ƤY  Try it online! 05AB1E, 17 bytes 0"D34çýη»"D34çýη»  Try it online! Befunge-98 (PyFunge), 31 bytes "2+,a<_@#-2$,k-'p11+1:g11+4+ff


Try it online!

Modification of a wrapping string literal quine that repeats printing prefixes until it prints everything.

Explanation:

"         Wrapping string literal that pushes the code backwards
2+,      Add 2 to the space and print as "
,a<    Reverse direction and print a newline
"         Push the code again, but the right way this time
+4+ff   Push a quote
g11        Get the counter at (1,1)
This is initially 32 (space)
p11+1:    Increment and store back at (1,1)
-'          Subtract 31 from the counter
,k             Print counter many times plus one
2$Swap and check if the next number on the stack is 2 2 _@# If so, end the program as this is the leftover 2 ,a Print a newline and repeat  Python 2, 72 bytes s,f="",'s,f="",%r\nfor i in f%%f:s+=i;print s' for i in f%f:s+=i;print s  Try it online! Pyth, 17 bytes j._jN*2]"j._jN*2]  Try it online! Pushy, 2826 24 bytes I"Ov:L69w6996w96L:vO"I  Try it online! Explanation: I"Ov:L69w79 \ String literal: push this to stack 96 \ Append backtick: I"Ov:L69w69 w \ Mirror: I"Ov:L69w6996w96L:vO"I 96 \ Append backtick: I"Ov:L69w6996w96L:vO"I \ We now have the source code, backwards, on the main stack. L: \ len(stack) times do: v \ Move last character to auxiliary stack O"I \ Print the auxiliary stack  Java 10, 202 bytes v->{var s="v->{var s=%c%s%1$c;s=s.format(s,34,s);for(int i=0;++i<s.length();)System.out.println(s.substring(0,i));}";s=s.format(s,34,s);for(int i=0;++i<s.length();)System.out.println(s.substring(0,i));}


Try it online.

Explanation:

part of the explanation:

• var s contains the unformatted source code.
• %s is used to input this String into itself with 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 of the explanation:

• for(int i=0;++i<s.length();) then loops i in the range [1, formatted_code_length)
• System.out.println(...) prints the String with trailing newlines
• s.substring(0,i) gets the substring of the formatted code in the character-range [0,i).

Japt-R, 11 bytes

CÇîQi"CÇîQi


Try it online!

If the leading newline isn't acceptable, here's a 15 13-byte alternative:

Dõ_îQi"Dõ_îQi


Try it online!

HQ9+, 1 byte

Q


Q prints the programs source code. Technically it is printing one character at a time, since there is only one character.

• This is an improper quine. – Dennis Nov 27 at 18:29
• What makes HQ9+ quines improper? – Embodiment of Ignorance Nov 27 at 20:13
• Aside from the fact that Q gives direct access to the source code (which is already forbidden), every character just encodes itself. In a proper quine, it must be possible to identify a section of the program which encodes a different part of the program. – Dennis Nov 27 at 21:01