9
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ This has been talked about before \$\endgroup\$ – mbomb007 May 2 '18 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\$ – Nathaniel May 2 '18 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\$ – Nathaniel May 2 '18 at 13:29
  • \$\begingroup\$ @mbomb007 this discussion is irrelevant and distracting and I will flag it for deletion. But the fact that I chose a Python quine is in fact a coincidence, because I hadn't seen that post when I posted this one. \$\endgroup\$ – Nathaniel May 2 '18 at 13:41
29
\$\begingroup\$

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.

\$\endgroup\$
  • \$\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\$ – Nathaniel May 1 '18 at 13:07

You must log in to answer this question.

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