10
\$\begingroup\$

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.

\$\endgroup\$
19
  • 1
    \$\begingroup\$ What's the winning criteria? \$\endgroup\$
    – DELETE_ME
    Nov 24, 2018 at 14:39
  • \$\begingroup\$ Whoops, sorry. If nobody submits a quine in 1 week from the last submission, the last submitter wins. \$\endgroup\$ Nov 24, 2018 at 14:44
  • \$\begingroup\$ Isn't that essentially the same as "no winning criteria"? ... (or "your score is 1. The lowest score wins." etc.) \$\endgroup\$
    – DELETE_ME
    Nov 24, 2018 at 15:20
  • \$\begingroup\$ (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. \$\endgroup\$
    – DELETE_ME
    Nov 24, 2018 at 15:22
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DJMcMayhem
    Nov 24, 2018 at 15:46

21 Answers 21

5
\$\begingroup\$

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.
\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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
select substr(rpad(
select substr(rpad(1
select substr(rpad(1,
select substr(rpad(1,2
select substr(rpad(1,24
select substr(rpad(1,240
select substr(rpad(1,240,
select substr(rpad(1,240,'
select substr(rpad(1,240,'|
select substr(rpad(1,240,'||
select substr(rpad(1,240,'||c
select substr(rpad(1,240,'||ch
select substr(rpad(1,240,'||chr
select substr(rpad(1,240,'||chr(
select substr(rpad(1,240,'||chr(3
select substr(rpad(1,240,'||chr(39
select substr(rpad(1,240,'||chr(39)
select substr(rpad(1,240,'||chr(39))
select substr(rpad(1,240,'||chr(39)),
select substr(rpad(1,240,'||chr(39)),5
select substr(rpad(1,240,'||chr(39)),53
select substr(rpad(1,240,'||chr(39)),53,
select substr(rpad(1,240,'||chr(39)),53,l
select substr(rpad(1,240,'||chr(39)),53,le
select substr(rpad(1,240,'||chr(39)),53,lev
select substr(rpad(1,240,'||chr(39)),53,leve
select substr(rpad(1,240,'||chr(39)),53,level
select substr(rpad(1,240,'||chr(39)),53,level)
select substr(rpad(1,240,'||chr(39)),53,level)f
select substr(rpad(1,240,'||chr(39)),53,level)fr
select substr(rpad(1,240,'||chr(39)),53,level)fro
select substr(rpad(1,240,'||chr(39)),53,level)from
select substr(rpad(1,240,'||chr(39)),53,level)from
select substr(rpad(1,240,'||chr(39)),53,level)from d
select substr(rpad(1,240,'||chr(39)),53,level)from du
select substr(rpad(1,240,'||chr(39)),53,level)from dua
select substr(rpad(1,240,'||chr(39)),53,level)from dual
select substr(rpad(1,240,'||chr(39)),53,level)from dual
select substr(rpad(1,240,'||chr(39)),53,level)from dual c
select substr(rpad(1,240,'||chr(39)),53,level)from dual co
select substr(rpad(1,240,'||chr(39)),53,level)from dual con
select substr(rpad(1,240,'||chr(39)),53,level)from dual conn
select substr(rpad(1,240,'||chr(39)),53,level)from dual conne
select substr(rpad(1,240,'||chr(39)),53,level)from dual connec
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect b
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by
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
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,2
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,24
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'|
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||c
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||ch
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(3
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39))
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),5
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,l
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,le
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,lev
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,leve
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level)
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level)f
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level)fr
select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;select substr(rpad(1,240,'||chr(39)),53,level)fro
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
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
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 d
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 du
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 dua
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
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
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 c
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 co
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 con
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 conn
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 conne
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 connec
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
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
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 b
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
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
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 l
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 le
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 lev
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 leve
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
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<
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<1
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<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;select substr(rpad(1,240,'||chr(39)),53,level)from dual connect by level<155;

154 rows selected.
\$\endgroup\$
3
\$\begingroup\$

Haskell, 100 98 bytes

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

\$\endgroup\$
0
3
\$\begingroup\$

Python 3.8 (pre-release), 54 bytes

exec(a:="s=''\nfor i in'exec(a:=%r)'%a:print(s:=s+i)")

Try it online!

I also have 2 variants of the same length :

exec(a:="s=''\nfor i in'exec(a:=%r)'%a:s+=i;print(s)")
exec(a:="s='';[print(s:=s+i)for i in'exec(a:=%r)'%a]")

How it works :

It is the standard "exec" quine in python: exec(a:="print('exec(a:=%r)'%a)") in which I added an iteration. This base quine is pretty usefull because it doesn't require to write all the added byte twice unlike the shorter a='a=%r;print(a%%a)';print(a%a) quine

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
5
  • \$\begingroup\$ uhhh... it doesn't really work. no chance of qualifying. \$\endgroup\$ Nov 24, 2018 at 17:08
  • \$\begingroup\$ Try now. I accidentally sent it before I was done. \$\endgroup\$ Nov 24, 2018 at 17:08
  • \$\begingroup\$ good one, it qualifies now \$\endgroup\$ Nov 24, 2018 at 17:09
  • \$\begingroup\$ I accidentally clicked run code snippet on the alert version... add a warning to that plz :P \$\endgroup\$
    – Quintec
    Nov 24, 2018 at 20:03
  • \$\begingroup\$ -1 by removing the space between of and `. \$\endgroup\$
    – Makonede
    May 18, 2021 at 20:01
2
\$\begingroup\$

Excel, 182 bytes

=LEFT(SUBSTITUTE("=LEFT(SUBSTITUTE(@,CHAR(64),CHAR(34)&@&CHAR(34)),ROW(1:182))",CHAR(64),CHAR(34)&"=LEFT(SUBSTITUTE(@,CHAR(64),CHAR(34)&@&CHAR(34)),ROW(1:182))"&CHAR(34)),ROW(1:182))

Added LEFT( ~ , ROW(1:182)) to standard quine.

Cheesy version, 32 bytes

=LEFT(FORMULATEXT(A1),ROW(1:32))
\$\endgroup\$
2
\$\begingroup\$

Vyxal Dj, 40 bits, 5 bytes

`I¦`I¦

Try it Online!

Explained

`I¦`I¦
     ¦   # Prefixes of
`I¦`     # the string "I¦"
    I    # with `I¦` prepended
# joined on newlines by the j flag
\$\endgroup\$
2
  • \$\begingroup\$ 6 bytes with j flag (or 5 with Vyncode) \$\endgroup\$
    – The Thonnu
    May 6, 2023 at 6:35
  • \$\begingroup\$ @TheThonnu I haven't reincorperated the golfing suggestion yet - all I did was a roll back because I was a little short on time and unable to reformat everything. \$\endgroup\$
    – lyxal
    May 8, 2023 at 6:33
1
\$\begingroup\$

Jelly, 14 bytes

“Ṿ;¹¹ƤY”Ṿ;¹¹ƤY

Try it online!

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 17 bytes

0"D34çýη»"D34çýη»

Try it online!

\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

PowerShell Core, 44 bytes

&($f={&{1..44|%{"&(`$f={$f})"|% s*g 0 $_}}})

Try it online!

Idea borrowed from this answer by bb216b3acfd8f72cbc8f899d4d6963, thank you!

\$\endgroup\$
1
\$\begingroup\$

Japt -R, 11 bytes

BõîQi"BõîQi

Test it

BõîQi"BõîQi
B               :11
 õ              :Range [1,B]
  î             :For each mould the following
   Q            :  Quotation mark
    i           :  Prepend
     "BõîQi     :    String literal
                :Implicit output joined with newlines
\$\endgroup\$
1
\$\begingroup\$

Thunno 2 N, 12 bytes

"DṘs+ƒ"DṘs+ƒ

Explanation

"DṘs+ƒ"DṘs+ƒ  # Full program
"DṘs+ƒ"       # Push the string "DṘs+ƒ"
       D      # Duplicate it
        Ṙ     # Get its representation
              # (surround by quotes)
         s+   # Prepend this to the string
           ƒ  # Get the new string's prefixes
              # Implicit output, joined by newlines

Screenshot

Screenshot (click to enlarge)

\$\endgroup\$
1
\$\begingroup\$

Julia 0.6, 91 bytes

Q="1:91.|>x->println(\"Q=\$(repr(Q));\$Q\"[1:x])";1:91.|>x->println("Q=$(repr(Q));$Q"[1:x])

Try it online!

Adapted from the Julia quine from Rosetta Code, which is based on repr

Requires at least Julia 0.6, but includes syntax that is deprecated in 0.7 and removed in 1.0

There exist shorter quines in Julia (32 and 35-byte quines based on @show, 37-byte quine based on eval), and it might be possible to adapt either of these methods.

\$\endgroup\$
0
\$\begingroup\$

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!

\$\endgroup\$
0
\$\begingroup\$

Pyth, 17 bytes

j._jN*2]"j._jN*2]

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Pushy, 28 26 24 bytes

`I"Ov:L69w69`96w96L: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:L69w69`96w96L:vO"I
                96           \ Append backtick: I"Ov:L69w69`96w96L: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
\$\endgroup\$
0
\$\begingroup\$

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).
\$\endgroup\$
0
\$\begingroup\$

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!

\$\endgroup\$
0
\$\begingroup\$

Julia, 63 bytes

(a=:([println(("(a=:($(a)))|>eval")[1:x]) for x = 1:63]))|>eval

Try it online!

The spaces and parenthesis are necessary because the code is stored in an Expr (AST), which will add them when interpolated.

based on this quine:
(a=:(print("(a=:($(a)))|>eval")))|>eval Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.