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

marked as duplicate by Joey, dmckee May 5 '11 at 16:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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
\$\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\$
  • \$\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\$ – dmckee May 3 '11 at 2:13
  • \$\begingroup\$ @dmckee is this a dupe per Joey's comment on the question, or not? \$\endgroup\$ – Jeff Atwood May 5 '11 at 8:07

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