The main idea is that the number of digits in a decimal number is roughly equal to its base 10 logarithm. For example, 10^3 = 1000 (3 + 1 digits), 10^4 = 10000 (4 + 1 digits), and so on. This allows us to approximate the range of the "elegant" value (tens, hunderds, thousands, ...).
Again, thanks for the suggestions. I published a new version here with some extra checks on random test generation (unconstrained depth and division by zero should be avoided now).
Thanks, I added some random tests. Do you think using eval is a big issue here? I don't see how it can be used to evaluate a non-infix expression effortlessly, and eval-based solutions which are not trivial seem alright to me.
Thanks, I do think that these two katas allow for somewhat different solutions (this one being a bit easier), but I see your point. Will it be considered different enough if I add non-valid expressions as possible inputs and require the user to return a separate value for them (e.g. null)?
The main idea is that the number of digits in a decimal number is roughly equal to its base 10 logarithm. For example, 10^3 = 1000 (3 + 1 digits), 10^4 = 10000 (4 + 1 digits), and so on. This allows us to approximate the range of the "elegant" value (tens, hunderds, thousands, ...).
Thanks for the translation!
Great, thanks for the translation!
Again, thanks for the suggestions. I published a new version here with some extra checks on random test generation (unconstrained depth and division by zero should be avoided now).
Thanks, I added some random tests. Do you think using
eval
is a big issue here? I don't see how it can be used to evaluate a non-infix expression effortlessly, andeval
-based solutions which are not trivial seem alright to me.Thanks, I do think that these two katas allow for somewhat different solutions (this one being a bit easier), but I see your point. Will it be considered different enough if I add non-valid expressions as possible inputs and require the user to return a separate value for them (e.g.
null
)?