Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
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.
Ok, cheers!
Use print for that, you can have as many as you want, and only return the expected data type.
So... I want return all my steps, that easier...
Your code is returning a wrong data type:
percentage = 100*11/15 = 73.33333333333333
<- that's a number, not a string.There're no issues with the tests.
Python
Pls, remake the tests! I am just writed:
def infected(s):
TAB return s
TypeError: bad operand type for abs(): 'str'
What???
When the answer is a
Float
with a representation error.If you want exact answers, use types with exact representations, not
Float
s andDouble
s.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.
It depends, you know? Of course, something trivial like
a + b / c
can be checked for strict equality, butceil(infected / total * 100)
is not guaranteed to equalceil(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?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?
If the problem is not reproducible let's close this for now then. Possibly a transient platform issue.
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.
Can you be more specific? "something wrong" ..?
Loading more items...