The title pretty much says it all. If I use tabs/spaces for making the code more readable, do I have to count them?
Also, are line breaks counted as one character(\n
) or as two (\r\n
)?
The title pretty much says it all. If I use tabs/spaces for making the code more readable, do I have to count them?
Also, are line breaks counted as one character(\n
) or as two (\r\n
)?
I think any whitespace unnecessary for execution may be excluded from the byte count, as long as it is mentioned in the answer and not required by the challenge.
In my opinion the best way to make your submission more readable is to post both
This allows for easy checking of your score, while still giving readers an easier way of understanding your code.
\n
, if possibleIf the program works correctly with \n
in the file instead or \r\n
, then you can claim the byte count of the program with \n
's. If, however, your interpreter/compiler requires you to use \r\n
, you should switch interpreters count the linebreaks as 2 bytes.
(This answer is quite similar to Pietu's but a bit stricter on the first question.)
This makes it easier for everyone else to check your score. For someone who doesn't know your language it can be hard to tell which spaces are necessary (and counted) and which not. Furthermore, I think people who post code with unnecessary spaces left in (but who don't count them) often don't test if all the spaces are actually unnecessary. In some languages I've used, I sometimes think I can just strip all spaces at the end, but then it breaks unexpectedly (I'm thinking Ruby and Mathematica, but there are certainly others).
If you want to provide a more readable version with indentation etc., include it in your answer separately, but the counted code should always appear first. As an example, here is one of my Mathematica answers which does this.
\n
, if possibleOn this account I agree with Pietu: unless your code only works with \r\n
, count it as a single character (i.e. usually as a single byte, unless you use UTF-16, say).