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.
Still having trouble with floating point comparisons:
I will mark the issue as resolved then
I believe I forked your solution with the fixed version? I don't quite know how it works it's my first solution in codewars sorry.
camelCase()
. (I fixed it quickly before more solutions fly in)Preloaded
, it is accessible from the solution.Random
with something gathered fromMath.random()
.Should be done now. Please let me know if there is anythng else!
The margin of error should be relative to the size of the result.
Otherwise, it'll still compare unequal for large results. For example:
Ok I've added margin for the doubles checking, I believe everything should be fine now?
Please let me know!
Even if there would be no assertion for arrays of floats, you can create one:
or something similar.
Tests should now show the expected vs actual value as you suggested.
As for the floating point errors, we don't exactly know how to handle that since we are comparing the Arrays themselves using assertArrayEquals, since we are giving the gravity constant and the rest of the values are Integers we didn't expect to have that issue.
Random tests are doing some weird checking, and gives clueless test feedback such as
The tests should be done to show better failure messages (it should show expected and actual value instead of how many values in the array match; we're not playing Mastermind here).
Speaking of which, the random tests are failing most probably because of floating point errors. Please use proper floating point checking with
assertApproxEquals
. The sample tests should do this as well.Should be fixed now!
Tests cannot be run:
Nitpick:
g
should be namedG
in initial code.g
is typically the acceleration on earth surface (aka9.81
).Similarly, parameter names are inappropriate: names like
force
should be about a single value, not on the list of values. Something likeforces
orforceArray
is more appropriate as its name.Java Translation