This question already has an answer here:
- How long is my number? 56 answers
Given a number between 0 and 999999999 and output its length.
This is what I managed to work out (scoring 36):
- Take ONE input string (with a trailing newline, LF) from STDIN.
- Output a number (between 0 and 9, see notes below) to STDOUT.
A trailing newline does not matter.
- Takes input that is not numbers (e.g.
7) but printable ASCII characters instead. The only newline LF is the last one. No CR. Beware of spaces and tabs. Reward: -3 bytes in score
- Takes input of a greater length. Reward: -3 bytes if 9 < max length < 232, -6 bytes if max length >= 232. Practical compiler/interpreter must exist.
- Complete both 1 and 2 for an extra -3 bytes.
Please note in your answer if you qualify for any bonuses.