Ad
  • Custom User Avatar

    If I return infections / population, I get 0.7333333333333333.
    If I return infections / population * 100, I get NaN!!
    Please help :(

    Edit: I opened the website in a new tab and it worked. Please don't ask me why. I am not available for comment at this difficult moment.

  • Default User Avatar

    ceil(infected / total * 100) is not guaranteed to equal ceil(infected * 100 / total)

    Which means that at least one of these is wrong. And how am I supposed to know that wrong results are acceptable? While I don't like approximate comparisons where there are unnecessary anyway, the main issue is that this behavior should be specified. How should I know not to overcomplicate my solution when imprecision is acceptable? Or how should I know where not to raise the issue? How about Fibonacci numbers by exponentiation? Should I raise an issue if the tests don't accept my double-precision floating point results because they have "rounding issues"?

    As a side note, if too many users have troubles with floating point errors, that's exactly because their errors have been accepted way too often to get used to it. Normalization of deviance.

  • Custom User Avatar

    Ok, cheers!

  • Custom User Avatar

    Use print for that, you can have as many as you want, and only return the expected data type.

  • Custom User Avatar

    So... I want return all my steps, that easier...

  • Custom User Avatar

    Your code is returning a wrong data type:

    percentage = 100*11/15 = 73.33333333333333 <- that's a number, not a string.

  • Custom User Avatar

    There're no issues with the tests.

  • Custom User Avatar

    Python

    Pls, remake the tests! I am just writed:

    def infected(s):
    TAB return s

    TypeError: bad operand type for abs(): 'str'

    What???

  • Custom User Avatar

    What would be your definition of when errors in results should be allowed

    When the answer is a Float with a representation error.

    If you want exact answers, use types with exact representations, not Floats and Doubles.

  • Custom User Avatar

    I have encountered a lot of katas with this problem already. I agree with @FArekkusu, that's why i mention the way to calculate it in the description.

  • Custom User Avatar

    It depends, you know? Of course, something trivial like a + b / c can be checked for strict equality, but ceil(infected / total * 100) is not guaranteed to equal ceil(infected * 100 / total). Why should the author explain how the result has to be calculated (problem #1) so the users would avoid rounding issues (problem #2) when you can avoid both?

  • Default User Avatar

    As in other similar cases, I disagree. What would be your definition of when errors in results should be allowed? Should the Multiply kata allow errors just in case someone should decide to solve it with a neural network that returns approximate results?

  • Custom User Avatar

    If the problem is not reproducible let's close this for now then. Possibly a transient platform issue.

  • Custom User Avatar

    It's very strange, I trained again in node v10 to will see error but now is everthing ok, maybe close tab or refreash helped.
    Every single run sample test tested only first case and returned error "expected NaN ... ", I just only remebered this.

  • Custom User Avatar

    Can you be more specific? "something wrong" ..?

  • Loading more items...