1
\$\begingroup\$

Possible Duplicate:
Line break formats and character numbers

Do we count newlines in ? I know newlines are almost redundant in , but imagine it's a language requirement.

How many characters does a newline take? CRLF (2) like in Windows? Or simply LF (1)?

\$\endgroup\$
1

2 Answers 2

5
\$\begingroup\$

If it's a language requirement, then see if your language allows bare LFs. If so, it's one byte. If your language requires CRLF (I think batch files do? Haven't checked), then you have to include both.

Remember, the principle is that you have to make the smallest valid program that does the task. The same principle governs how much whitespace needs to be counted: as little whitespace as is required to make the program valid and behave according to spec.

(Some people make bogus rules like "whitespace characters don't count towards the code size"; for such contests, any submission in Whitespace is guaranteed to be shortest.)

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

In some languages they work just like whitespace, so you could replace all the spaces with newlines. As far as I know they are usually counted

\$\endgroup\$
2
  • \$\begingroup\$ It is worth noting that Georges' script attempts to understand which newlines are necessary (counted) and which are simply to keep the blocks from needed endless scrolling (uncounted). \$\endgroup\$ Commented May 3, 2011 at 2:13
  • \$\begingroup\$ @dmckee is this a dupe per Joey's comment on the question, or not? \$\endgroup\$ Commented May 5, 2011 at 8:07

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