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

3

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.

Andrew

Posted 2018-11-24T14:34:42.647

Reputation: 2 067

1What's the winning criteria? – user202729 – 2018-11-24T14:39:54.307

Whoops, sorry. If nobody submits a quine in 1 week from the last submission, the last submitter wins. – Andrew – 2018-11-24T14:44:01.520

Isn't that essentially the same as "no winning criteria"? ... (or "your score is 1. The lowest score wins." etc.) – user202729 – 2018-11-24T15:20:16.920

(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 – 2018-11-24T15:22:50.103

1Hello, 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 [tag:code-golf], you can always improve your program and your score. – James – 2018-11-24T15:46:39.703

yeah, i just wanted to do a test challenge tbh, the next one will indeed have a winner – Andrew – 2018-11-24T16:08:29.717

@DJMcMayhem Instead of code-golf, i think this is one of the few times where code-bowling would be appropriate. It is far easier to create a one byte solution to this than a 1000 byte solution, at first glance. – Quintec – 2018-11-24T16:14:19.020

so reverse code golf? ok, i did a cool thing at least – Andrew – 2018-11-24T16:15:38.443

@Quintec This is just a generalized quine challenge. Nothing prefvents a program to be arbitrarily long. – user202729 – 2018-11-24T16:18:05.233

yee. now that i mention it, the winning criterium may be the most interesting generalized quine – Andrew – 2018-11-24T16:18:57.833

@quintec But this isn't code-bowling either. If it was code-bowling, you can do something to improve your own programs score. In this challenge, there isn't even a score, you just cross your fingers and hope that no one else answers. – James – 2018-11-24T16:21:46.763

eh, i realized how much of a fool i was. now it's a mini-competition – Andrew – 2018-11-24T16:43:16.283

I'm voting to close this question as off-topic – l4m2 – 2018-11-24T17:06:12.140

newlines it is. – Andrew – 2018-11-24T23:35:17.910

Does the program have to print a substring of itself, or can the characters be in any order? Does the program ABCDE have to print A AB ABC ABCD ABCDE, or can it print A BC CDE BCDE ABCDE? Or D BD ACE ACDE ABCDE? – mbomb007 – 2018-11-25T05:31:53.350

A, AB, ABC, ABCD, ABCDE. – Andrew – 2018-11-25T09:25:00.370

HQ9+ Q will be making an appearance fwen this question is reopened. – Sparr – 2018-11-25T23:25:06.457

@Sparr I assume quines would still have to follow the community consensus on valid quines, of which the HQ9+ quine does not – Jo King – 2018-11-27T01:05:03.797

There are now 4 answers beating mine, you should update the checkmark (currently this is the winning answer).

– ბიმო – 2018-11-27T19:37:26.547

Answers

1

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.

Dennis

Posted 2018-11-24T14:34:42.647

Reputation: 196 637

3

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.

ბიმო

Posted 2018-11-24T14:34:42.647

Reputation: 15 345

2

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.

Dr Y Wit

Posted 2018-11-24T14:34:42.647

Reputation: 511

2

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

ბიმო

Posted 2018-11-24T14:34:42.647

Reputation: 15 345

1

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.

haykam

Posted 2018-11-24T14:34:42.647

Reputation: 784

uhhh... it doesn't really work. no chance of qualifying. – Andrew – 2018-11-24T17:08:10.667

Try now. I accidentally sent it before I was done. – haykam – 2018-11-24T17:08:44.293

good one, it qualifies now – Andrew – 2018-11-24T17:09:57.630

I accidentally clicked run code snippet on the alert version... add a warning to that plz :P – Quintec – 2018-11-24T20:03:10.227

1

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

Jo King

Posted 2018-11-24T14:34:42.647

Reputation: 38 234

1

Jelly, 14 bytes

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

Try it online!

dylnan

Posted 2018-11-24T14:34:42.647

Reputation: 4 993

1

05AB1E, 17 bytes

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

Try it online!

Cowabunghole

Posted 2018-11-24T14:34:42.647

Reputation: 1 590

0

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!

Cowabunghole

Posted 2018-11-24T14:34:42.647

Reputation: 1 590

0

Pyth, 17 bytes

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

Try it online!

Cowabunghole

Posted 2018-11-24T14:34:42.647

Reputation: 1 590

0

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!

Oliver

Posted 2018-11-24T14:34:42.647

Reputation: 7 160

0

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

FlipTack

Posted 2018-11-24T14:34:42.647

Reputation: 13 242

0

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

Kevin Cruijssen

Posted 2018-11-24T14:34:42.647

Reputation: 67 575