Take a stand against long quine lines

28

or: Build a vertical quine

Inspired by Take a stand against long lines.

Your task is to build a vertical quine with as short a line length as possible.

Scoring

Shortest line length (excluding newlines) wins, with criteria as a tie-breaker.

Line length is determined as the longest line in your program excluding the line break character.

For example:

$_=
Q.
P

has a line length of 3 and a byte count of 8, whilst:

Q
$
_
P

Has a line length of 1 and a byte count of 7 (assuming no trailing newline).

Rules

Quines must meet the community definition of a quine.

Standard loopholes are forbidden.

Dom Hastings

Posted 2018-02-19T12:16:28.810

Reputation: 16 415

Does the rule of the challenge this is inspired from apply here as well? ("All line breaks must be meaningful. Line breaks that can be removed and adjacent lines directly concatenated without an impact on the output, must be removed.") – Kevin Cruijssen – 2018-02-19T13:27:06.083

6@KevinCruijssen No, I wanted this challenge to have a bit more freedom to encourage shorter line lengths! It was the one thing I wanted to change in the other challenge! – Dom Hastings – 2018-02-19T13:30:56.580

Answers

31

Lenguage, line length 0, ≈ 1.01 × 10805 bytes

The source code consists of

10124204951141713202533972929121310016060433092338061822344361345785088607872212687519180665846846689047959498775873817205954910072327976407177053174071436371843670134990737172675632938993247496933911137703773908536875512359091727633452506044935740750830240213878294804481182083555147915724921824921475110508228264569693355158523956426011218344830576542194309867719995259333487662608933990607888012376767799159279952780093033761421596267435996052643805835600325453580090964941176722519904997142820547696122795384058768166716813179490118821654787005844786013890425692181280317909786461426684986082270532414940905922244777135016193088362341771414388821075092853157152933099269703875111747946164773211049512395358715902962437487134522781505709420586981997748912591875626029183292826655753251235587052422561943

linefeeds, which encodes the brainfuck program that follows.

>>++++++++>+++>+++>+>+>+>+>+>+>+>+++>+>+>+>+>+>+>+>+>+++>+>+>+>+>+>+>+>+>++++++++>++++>++++++++>++++>+++++++>++>+++>+>+++>++>+++>+++>+>+>+>+>+>+>+>+>++++>++++>+++++++>+>++++>++++++++>++>+++++++>+++>++++++++>++>+++++++>+++>++++++++>++>+++++++>+++>++++++++>++>+++++++>+++>++++++++>++>+++++++>+++++>+>+>+>+>+>+>+>+>+>+>++++++++>++++>+++++++>+++++++>+>+>+++>+>+>+>++++++++>+++>+++++++>+>+++>+>+++>+>+++>+>++++++++>++++>++++++++>++++>++++++++>++++>++++>+>+++>+++>++>+++++++>+++++++>+>+>+>++++++++>+++>+>++++++++>++++>+>+++>++>+++++++>++>+++++++>++++>++++>++++++++>+++>++++++++>+++>+++>+>++++>++++>++>+++++++>+++>+++>++++++++>++++>+>+++>++>+++++++>++++>++++>+++++++>+++>+++>+++>+++>++++++++>++++>++++>+>+++>+>+++>++>+++++++>+++++++
[
    [->+>+<<]
    >>>>[<<[->+<]>>[-<<+>>]>]
    <<[-[->+<]+>]+++
    [[->>+<<]<]<
]
+>+>+>+
[>]+++>++
[
    [<]++++++++++.[-]
    >[-]>[-]>[-]>[-]
    <+[<<++++++++>>->+>-[<]<]
    ++++++++>++++++++>+++++++>>
]

The source code is mostly identical to @jimmy23013's radiation-softened Lenguage quine, minus the . at the end, with ++++++++++.[-] replacing . to print linefeeds instead of null bytes, and the corresponding changes to the data section on line 1.

Dennis

Posted 2018-02-19T12:16:28.810

Reputation: 196 637

I knew it was inevitable! I did want an inclusive question though. I wonder if anyone can beat this... – Dom Hastings – 2018-02-19T16:15:42.007

Lord, this language is the definition of why code-bowling isn't well-received, that's a cool one for sure... Can't believe "Hello World" would require "about 1.75*10**76 yottabytes in ASCII" – Magic Octopus Urn – 2018-02-21T15:40:57.667

I've asked on meta about accepting a theoretical answer.

– Dom Hastings – 2018-03-23T06:59:26.843

You can golf more than 99% of the code by using ]++++++++ ++.--> – jimmy23013 – 2018-06-22T15:26:05.780

28

JavaScript, line length 1, 960 956 928 bytes


[
t
,
r
,
u
,
e
,
f
,
a
,
l
,
s
]
=
!
0
+
[
!
1
]
;
[
,
n
,
d
,
,
q
,
i
]
=
t
.
a
+
t
V
=
[
]
[
f
+
i
+
n
+
d
]
;
[
,
,
,
c
,
,
,
o
,
,
_
,
,
,
,
,
y
,
z
]
=
V
+
0
F
=
V
[
E
=
c
+
o
+
n
+
s
+
t
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=t.a+t
V=[][f+i+n+d];[,,,c,,,o,,_,,,,,y,z]=V+0
F=V[E=c+o+n+s+t+r+u+c+t+o+r]
P=(1+e+2+3-4+t)[2]
f=F(r+e+t+u+r+n+_+a+t+o+(0+{})[3])()(3*4+[][E][n+a+(0[E]+0)[9+2]+e])[1]
F(a,a+l+e+r+t+y+a+P+q+P+a+P+q+z)`

Explanation

Whew. Settle in for a ride here, because this is gonna be a treacherous journey...

I spent a long time trying to figure out how to solve this challenge with length 1—no built-ins (directly, anyway), keywords, or even arrow functions—before realizing that it is easily possible with JSF***, which can evaluate any JavaScript code while avoiding any multi-byte tokens. But a JSF solution would easily be thousands of bytes long, if not tens or hundreds of thousands. Thanksfully, we aren't limited to just ()[]+!—we have all of ASCII at our disposal!

I decided to start by golfing the essential building blocks of JSF—the characters that can be built up into strings to "unlock more features," so to speak. We can't use strings directly to get characters, as that would require lines of length 3. So instead, we steal a trick from JSF, getting a few chars from literals that can be built up with single-byte tokens:

JSF***   Used here   Value        Chars unlocked
!![]     !0          true         true
![]      !1          false        fals
[][[]]   t.a         undefined    ndi

From these we can expand outward, starting with [].find, which is a Function object. Converting this to a string function find() { ... gives us access to c, o, space (_), and parentheses (y and z). Perhaps more importantly, we now have access to its constructor, the Function function—which, inceptional as it may sound, gives us the ability to execute code by building a string, passing it to Function(), and then calling the function generated.

I should probably mention the overall method used by the program itself. As of 2015, JavaScript has this really cool feature called "tagged templates," which not only allows unescaped newlines in strings, but also lets us call a function with a string literal directly (in a way; myFunc`abc`; is roughly equivalent to myFunc(["abc"])). If we put the function call as the last thing in the program, the general structure will look like this:

code;func`code;func`

All func has to do then is output its argument, followed by a backtick, then its argument again, and a second backtick. Assuming we have the argument in a and a backtick stored in f, we can accomplish this with the code alert(a+f+a+f). However, at the moment, we are missing + and the backtick itself. + (stored in P) isn't hard; we steal another trick from JSF, building the string 1e23, converting to a number, then back to a string, giving "1e+23".

Getting a backtick is a bit more complicated. At first, I tried obtaining String.fromCharCode, but finding a C turned out to be nearly as difficult. Fortunately, atob is easy enough to obtain (Function("return atob")(); b is generated from 0+{}, which gives [object Object]) and can give any ASCII char, if a proper magic string is found. A short script gave me 12A as one of the options, which can conveniently be found in 12Array (a bit shorter to generate, thanks to [].constructor[n+a+m+e]; m is found in 0 .constructor+0: "function Number() { ...").

Finally, we stick everything together. We assign the backtick to variable f, but since we can't use it directly in the function string, we instead set variable q to the letter f and use that instead. This makes our final string a+l+e+r+t+y+a+P+q+P+a+P+q+z, or "alert(a+f+a+f)". We then feed this to Function(), feed the our finished code to the result, and voila, we have a JavaScript quine with no more than one char per line!


My head feels terrible at the moment, so please inquire about any mistakes I've made or things I've missed in this explanation, and I'll get back to you after I've had some rest...

ETHproductions

Posted 2018-02-19T12:16:28.810

Reputation: 47 880

Nice! Although really not a JS programmer, I can guess the gist of this from what I've read about JSFuck, but I'd like an explanation especially of that f= line. – Ørjan Johansen – 2018-02-20T02:08:00.997

1@ØrjanJohansen Sorry, I've been trying to write an explanation for the whole thing, but it's not going very well so I'll just answer your question quickly: it's a convoluted way to set f to a single backtick. The line itself is equivalent to f=atob("12Array")[1]. The other trick is that q is actually set to the letter f in the first line, so that in the F(...) line, I can use it to put the letter f in the evaluated string, since variable f is no longer set to that letter. The a+l+e+r+t+y+a+P+q+P+a+P+q+z is equivalent to "alert(a+f+a+f)". – ETHproductions – 2018-02-20T02:57:45.080

Great, now I understand it! You might mention what 0+{} and 0[E] stringify to in order to get b and m. – Ørjan Johansen – 2018-02-20T04:50:11.940

Nice indeed! Much smaller than my attempt, although we used a simar approach!

– Dom Hastings – 2018-02-20T06:22:32.393

@DomHastings So long the link doesn't even work ;-) – ETHproductions – 2018-02-20T22:35:58.297

Well, that's embarrassing! – Dom Hastings – 2018-02-21T00:52:54.797

@ØrjanJohansen Done, thanks for the suggestion. – ETHproductions – 2018-02-21T15:27:56.717

+1 for being a true quine and not calling Function.toString. – Neil – 2018-02-26T10:07:20.870

@Neil If you have a length-1 solution that uses Function.toString, I'm all ears, because I couldn't find one myself... – ETHproductions – 2018-02-26T15:54:01.370

15

Haskell, line length 6, 400 343 336 bytes

{main=
putStr
$s++(s
>>=(++
":\n")
.show)
++
"[]}";
s='{':
'm':
'a':
'i':
'n':
'=':
'\n':
'p':
'u':
't':
'S':
't':
'r':
'\n':
'$':
's':
'+':
'+':
'(':
's':
'\n':
'>':
'>':
'=':
'(':
'+':
'+':
'\n':
'"':
':':
'\\':
'n':
'"':
')':
'\n':
'.':
's':
'h':
'o':
'w':
')':
'\n':
'+':
'+':
'\n':
'"':
'[':
']':
'}':
'"':
';':
'\n':
's':
'=':
[]}

Try it online! I'm not aware of a way around putStr, thus the line length of 6. The outer curly braces allow to get rid of the otherwerwise required indention after a newline within a single declaration.

Laikoni

Posted 2018-02-19T12:16:28.810

Reputation: 23 676

12

><>, 22 bytes, line length 1

/
v
o
a
o
^
}
-
d
:
"

Try it online!

-6 bytes thanks to Emigna.

Erik the Outgolfer

Posted 2018-02-19T12:16:28.810

Reputation: 38 134

12

CJam, line length 1, 16 13 bytes

"
_
p
"

_
p

Try it online!

It's a small miracle that inserting newlines into the standard quine {"_~"}_~ even shorter standard quine "_p"␊_p does the right thing. (Thanks, Martin!) The trailing newline is necessary.

Explanation (with • as newline)

"•_•p•"        Push that string.
       ••      Do nothing.
         _     Duplicate the string.
          •    Do nothing.
           p   Pop it and print it with quotes and a newline: "•_•p•"•
            •  Do nothing.

On termination, what's left on the stack is printed (•_•p•), yielding total output "•_•p•"••_•p•.

Lynn

Posted 2018-02-19T12:16:28.810

Reputation: 55 648

2All I have to say is ... •_• – corsiKa – 2018-02-20T17:51:49.803

6

Haskell + CPP, line length 2, 705 237 bytes

m\
a\
i\
n\
=\
p\
u\
t\
S\
t\
r\
$\
(\
:\
"\
\\
\\
\\
n\
"\
)\
=\
<\
<\
s\
+\
+\
s\
h\
o\
w\
 \
s\
;\
s\
=\
"\
m\
a\
i\
n\
=\
p\
u\
t\
S\
t\
r\
$\
(\
:\
\\
"\
\\
\\
\\
\\
\\
\\
n\
\\
"\
)\
=\
<\
<\
s\
+\
+\
s\
h\
o\
w\
 \
s\
;\
s\
=\
"\

Try it online! Using the flag -CPP which enables the C pre-processor allows us to use a backslash at the end of a line to continue it on the next line.

The actual code is main=putStr$(:"\\\n")=<<s++show s;s="<data>".

Edit: A casual -468 bytes thanks to Ørjan Johansen!

Laikoni

Posted 2018-02-19T12:16:28.810

Reputation: 23 676

1

It saves a lot of escaping to change that to main=putStr$(:"\\\n")=<<s++show s;s="<data>". Try it online!

– Ørjan Johansen – 2018-02-19T18:45:12.223

5

Rust, line length: 5, bytes: 301 299

Try it online

Despite how it looks, this isn't an esoteric programming language, there is just a lot of format line noise.

Vertical length of 5 was chosen to be able to use print. I don't think there is a way to print that would have shorter vertical length, declaring C functions uses extern keyword, stdout is 6 bytes long, write is 5 bytes long, no_main is 7 bytes long (main is usually a function ;)).

fn
main
(){
let
t=(
r#"fn
main
(){
let
t=("#
,r#")
;
print
!(
r#"{}
r#"{
}"{}
,r#"{
}"{},
r#"{
}"{}
{}{}{
}{
}""#,
r#"
,t.0,
t.0,
'#',
t.1,
'#',
t.2,
'#',
t.1,
'#',
t.2,
'}'
)"#
)
;
print
!(
r#"{}
r#"{
}"{}
,r#"{
}"{},
r#"{
}"{}
{}{}{
}{
}"#
,t.0,
t.0,
'#',
t.1,
'#',
t.2,
'#',
t.1,
'#',
t.2,
'}'
)}

Konrad Borowski

Posted 2018-02-19T12:16:28.810

Reputation: 11 185

Isn't it horizontal length? – anatolyg – 2018-02-20T00:09:42.170

@anatolyg fixed – Konrad Borowski – 2018-02-20T05:27:51.177

Raw string nesting without syntax highlighting makes this impossible to interpret. I don't think cargo fmt would even help here... – CAD97 – 2018-02-20T05:36:47.800

@CAD97 If what you want is syntax highlighting, https://play.rust-lang.org/ highlights this correctly which is why I used it instead of TIO for "Try it online" link.

– Konrad Borowski – 2018-04-07T09:18:23.950

4

05AB1E, Line length: 1, Byte count: 43

2
"
D
3
4
«
ç
¶
ì
ý
Ô
"
D
3
4
«
ç
¶
ì
ý
Ô


Try it online!

Emigna

Posted 2018-02-19T12:16:28.810

Reputation: 50 798

2

Japt, line length 1, 20 bytes

Based off the standard Japt quine by ETHproductions.

"
i
Q

²
"
i
Q

²

Try it here!

Mr. Xcoder

Posted 2018-02-19T12:16:28.810

Reputation: 39 774

2

JavaScript (ES6), line length 3, 17 bytes

f=
_=>
`f=
${f
}`

kamoroso94

Posted 2018-02-19T12:16:28.810

Reputation: 739

2

Red, line-length: 10, 49 bytes

s: [prin [
    "s:"
    mold s
    "do s"
]] do s

Try it online!

This in fact is a Rebol quine

Explanation: Red/Rebol's mold follows the coding style of putting 4 spaces offset.

s: [prin [     ; s is a block; print the following: 
    "s:"       ; literal "s:"
    mold s     ; the representation of the block itself - all between []
    "do s"     ; literal "do s"
]] do s        ; evaluate the block

Galen Ivanov

Posted 2018-02-19T12:16:28.810

Reputation: 13 815

2

RProgN, 3 bytes, line length 1

0
0

Try it online!

A copy of Dennis' answer here (go upvote him too)

This is a conforms to our current definition of a proper quine, as the first 0 encodes the second 0 and vice-versa.

Jo King

Posted 2018-02-19T12:16:28.810

Reputation: 38 234

3It's much too bad we haven't come to a consensus on a better definition :-/ – ETHproductions – 2018-02-20T01:43:53.413

@ETHproductions Well, there's some support for this definition.

– Martin Ender – 2018-02-21T09:44:52.767

2

RProgN 2, L = 1, B = 15 bytes

«
Ø
.
`
-
S
`
.

This is equivilent to the program:

«Ø.`
-S`
.

Breakdown

« first pushes a function representing implicitly the rest of the program to the stack, and then continues execution. Ø. appends an empty string to the function, which stringifies it. This will always stringify like the equivilent program, due to newlines being no-ops. `\n- Removes all newlines from the string, now looking like «Ø.`=S`.. S then converts it to a stack of single characters, and `\n. joins the stack by newlines, returning the expected program.

Try it online!

ATaco

Posted 2018-02-19T12:16:28.810

Reputation: 7 898

2

Underload, line length 1, 20 bytes

(
:
a
S
S
)
:
a
S
S

Try it online!

This is just the standard Underload quine with newlines appended. Requires an implementation like the TIO one which ignores unknown command characters.

The part in () is a string literal put on the stack, : duplicates it, a wraps the top stack entry in parentheses, and S prints.

Ørjan Johansen

Posted 2018-02-19T12:16:28.810

Reputation: 6 914

2

Perl 5, 259 bytes


$
_
=
p
.
r
.
i
.
n
.
t
.
q
{

'
$
_
=
p
.
r
.
i
.
n
.
t
.
q
{
'
,
&
{
I
.
"
X
0
y
h
~
"
^
"
E
O
0

y
"
.
x
}
(
$
_
,
6
,
-
1
)
,
'
}
;
&
{
I
.
"
X
0
o
k
h
~
"
.
(
Y
|
p
)
^
"
E
O
0
|
f
s
o
"
}
'
}
;
&
{
I
.
"
X
0
o
k
h
~
"
.
(
Y
|
p
)
^
"
E
O
0
|
f
s
o
"
}

Try it online!

Verification.

Dom Hastings

Posted 2018-02-19T12:16:28.810

Reputation: 16 415

1

Javascript (ES6 REPL), full-program, line-length: 3, byte-count: 31

(
f=
_=>
`(
f=
${f
}
)
()`
)
()

This is a port of @kamoroso94's answer to a self-contained full program.

If anybody finds a way to strip off some bytes without adding more to the line-length feel free to comment :)

Brian H.

Posted 2018-02-19T12:16:28.810

Reputation: 513

Note that this still doesn't actually output anything, unless you run it in an REPL. I would call it JavaScript (ES6 REPL) – ETHproductions – 2018-02-19T15:51:42.063

oh shoot, way to used to chrome's console... – Brian H. – 2018-02-19T15:54:51.593

1

Pip, line length 1, 35 bytes


V
Y
"
[
`
V
Y
`
y
]
.
C
:
3
.
4
"

Try it online!

Based on the shortest known Pip quine, V Y"`V Y`.RPy". The main difficulty in squishing it to line length 1 is RP, which can't be split over two lines. But in this case, all RP (repr) does is wrap the string in double quotes, which we can do directly.

Here's an explanation based on a horizontal version:

V Y"[`V Y`y].C:3. 4"
  Y"               "  Yank this string into the variable y
V                     and eval it
                      The code that is eval'd:
    [      ]           Build a list containing:
     `V Y`              this Pattern object (used for regex, but here useful as a
                          string-like object that doesn't need double quotes)
          y             y, the whole string
               3. 4    Concatenate 3 and 4 to make 34 (since the 2-digit number won't work
                         in the vertical version)
             C:        Convert to ASCII character (: forces the precedence lower than .)
            .          Concatenate the " to the end of each list element
                      The resulting list is printed, concatenated together, with a
                        trailing newline

DLosc

Posted 2018-02-19T12:16:28.810

Reputation: 21 213

1

Befunge-98, 41 bytes

^
@
,
,
a
-
1
*
5
7
|
 
#
!
a
#
:
,
^
$
"

Try it online!

Really just a normal quine turned sideways, with some extra stuff to print newlines.

Jo King

Posted 2018-02-19T12:16:28.810

Reputation: 38 234