A simple question really: how strict is this community (or how strict does it want to be) about newlines when it comes to quines?

For example, is the Python quine

_='_=%r;print _%%_';print _%_

29 bytes, or is it 30 (including the trailing newline, since that's printed in its output)?

  • \$\begingroup\$ This has been talked about before \$\endgroup\$
    – mbomb007
    Commented May 2, 2018 at 13:13
  • 2
    \$\begingroup\$ @mbomb007 that's a comment on a post on the main site, it's hardly a discussion of policy. \$\endgroup\$
    – N. Virgo
    Commented May 2, 2018 at 13:21
  • \$\begingroup\$ I see. It's actually a complete coincidence that the example is the same - I got from Stack Exchange via a Google search for "short python quine". \$\endgroup\$
    – N. Virgo
    Commented May 2, 2018 at 13:29

1 Answer 1


If a newline is printed it must be part of the source code

A lot of languages have multiple functions for printing, some of them will include a newline and some of them won't. It's the programmer's choice what function they use, if they choose to print a trailing newline it must be included in the source code because it's part of the output.

Questions like for example KC challenges state whether it's fine to include newlines or not. So if a challenge does not specify whether that's ok, it should be required by default. The tag-wiki defines a quine as:

A quine is a program which produces its source as output.

It doesn't say "which produces its source plus additional characters as output", newlines are not really different from other characters.

I'm guessing this question targets the Golf you a quine for great good! challenge which has an even less ambiguous definition (emphasis mine):

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

This means no trailing spaces, non-printable chars, unicode characters or newlines. If we would ask whether it's fine to print an additional a character, nobody would say that this is fine (unless the rules explicitly say so). Newlines should be treated the same as other characters.

Furthermore (and most importantly) most answers that currently include a newline as part of their output can be easily fixed[citation needed] and we won't lose valuable content by enforcing the rules.

  • \$\begingroup\$ I fully agree and will most likely accept this when it has a bit more support. (The question comes from a discussion on Write a Quine Suite.) \$\endgroup\$
    – N. Virgo
    Commented May 1, 2018 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .