Wiki
string counting add tag
Community
Counting your code's length is essential for code golf competitions. Make sure you do it right by following these guidelines. Ask a Meta question if in doubt.
1. **Include your character encoding in your answer** or go with the default; bytes when stored as UTF-8. This is important for languages with custom code pages or tokens-based representation.
1. **Flags are not counted.** Command line flags are considered part of the language, and should be presented as such in answer headings, e.g. ``# mylang `-a`, 123 bytes``. This includes flags to select language with a multi-language compiler.
1. **The REPL is considered a separate language.** Not only can you often avoid explicit print commands, you might also be able to use other tricks.
1. **If multiple files/folders are used, add one byte for each additional file after the first.**
1. **If the same file is used multiple times, it counts as multiple separate files.**
1. **Don't count the assignment necessary to name your lambda/function.** However, if your code needs to call itself and doesn't have a syntax for that, or if it consists of two functions calling each other by name, then you must count the naming.
1. **Count the code as posted.** If there is unnecessary white-space, remove it.
1. **Count line breaks as single bytes,** unless that would cause your code to stop working.
1. **Count macros as stated,** not as the text they're expanded into.
1. **Count the source code size,** even if your language ignores one or more bits of every byte. Only if your language can handle code in a packed format, can you count it as such, but rounded up to the nearest byte.
1. **Use the saved file size** if your language is not text-based.
1. **Machine code has the size of the executable.**
1. **Assembly has the size of the source code.**
1. **Ignore trailing null-bytes** if you are using a fixed-size memory machine.
1. **Ignore trailing white-space** if your code can run without it.
1. **Control codes are one byte each.**

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.