Solution ≠ outputting an expression
I'll phrase this, this way: imagine there is a hypothetical question:
Given n
output the sum of all numbers from 1
to n
Okay, so the answer should calculate this. Now let's say I wrote an answer and the output for input 5
is:
5(5+1)/2
Does this seem right? No. But I'm not completely against outputting expressions...
Fractions
If an answer were to output something like 2/3
I'd say this is fine as it can be considered a fraction representation of a number. An expression evaluates to a number, it is not a representation of a number, unlike fractions. So I don't see any reasons to ban fractions. Every language which supports fractions that I know of simplifies them so I'd say that fractions should be simplified.
Format of numbers
If a number has leading zeros (e.g. 00075
), or doesn't have a leading zero of a decimal (e.g. .43
), I'd say this is fine. An answer should really be focusing on solving the problem, not trimming leading zeros to conform to an overly-strict output format. Scientific notation applies as the same as above. As long as it conforms to the required precision. It is a perfectly acceptable representation of a number.
Symbolic constants
I'm not completely decided on this. For complex numbers, if I were to output: 5i
, for complex numbers, that would be fine.
For cases of π
and other constants, this is a bit more different, I don't know of any language that outputs π
itself rather than its value. I'd say maybe not as, for example in JavaScript, instead of doing Math.PI
, I could just do +"pi"
and save a couple of bytes, which seems like avoiding to actually calculate the answer to save bytes. I'd say challenges could override this on a case-by-case basis but I'm not completely decided on this.