In a recent question for which the correct output for
1 is zero, an answer output
; i.e, nothing. Is this an acceptable base-10 representation for zero?
No, besides exceptions.
The challenge linked obviously requires the output to be a number for valid inputs.
The empty string is not a number. The fact that empty strings evaluate to 0 in some languages doesn't justify its use as the number 0. Otherwise I could argue that
"a" is valid to represent
97 in outputs because it's the corresponding ASCII code.
The only case I can think of where outputting
"" for 0 is OK is when your output is in unary.
The mathematical definition of a base-10 representation is:
Where an...a1a0 is the base-10 representation. The value of the empty string is well-defined as the empty sum, 0.
The empty string can be considered a more consistent representation than
0, since it follows the convention that numbers have no leading zeroes.
In both the mathematical base conversion algorithm:
def frombase(array,base): ret = 0 for digit in array: ret = ret * base + digit return ret
and in many languages interpretation (e.g.,
[int]""), the empty string evaluates to zero.
Thus, for a challenge requesting decimal output, an empty string is acceptable to output for zero.