72
6
Anybody can make the output of a program bigger by adding characters, so let's do the exact opposite.
Write a full program, an inner function or a snippet for a REPL environment in a language of your choice that satisfies the following criteria:
Your code must be at least 1 character long.
Running the original code produces x characters of output to STDOUT (or closest alternative), where 0 ≤ x < +∞.
Removing any arbitrary single character from the original code results again in valid code, which produces at least x + 1 characters of output to STDOUT.
Neither the original code nor the modifications may produce any error output, be to STDOUT, STDERR, syslog or elsewhere. The only exceptions to this rule are compiler warnings.
Your program may not require any flags or settings to suppress the error output.
Your program may not contain any fatal errors, even if they don't produce any output.
Both the original code and the modifications must be deterministic and finish eventually (no infinite loops).
Neither the original code nor the modifications may require input of any kind.
Functions or snippets may not maintain any state between executions.
Considering that this task is trivial is some languages and downright impossible in others, this is a popularity-contest.
When voting, please take the "relative shortness" of the code into account, i.e., a shorter answer should be considered more creative than a longer answer in the same language.
2While the 1 byte solution is impressive, it would be more impressive to see who can come up with the highest ratio of x:x+n. i.e. the length of normal output compared to the average length of output when any one character is removed. Adds an extra challenge to this question in my opinion. – Trent – 2015-06-24T02:49:29.137
@FizzBuzz Easy:
111111111111111111^111111111111111111
(if you meant the lowest ratio). – jimmy23013 – 2015-06-24T12:30:27.5372Aw, just noticed 'no infinite loops.' I was working on creating a ><> program that would create output faster if an one character was removed, such that after a constant
k
instructions, the output of each program is strictly greater than the output of the original from then on (because the other programs would loop faster or output more each loop). It was looking pretty interesting. Maybe I'll see if I can finish it anyway, and make another challenge. – mbomb007 – 2015-06-24T17:28:21.600An interesting scoring metric for this challenge could be "most unique characters, ties go to shortest length". We would then try to get all the characters in a string literal though. – lirtosiast – 2015-07-01T23:11:22.403
What is meant by an inner function? – dfeuer – 2019-04-01T04:16:46.400