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.
There are floats among the given numbers; thus, using
eval
andstr
to multiply the numbers, like you did, loses precision due to rounding.Try to find another way of multiplying the numbers that doesn't involve strings.
Do note that this is only a problem due to floats, and if you were given only integers, there would be no problem with your approach, except for suboptimal performance, of course.
Fixed in latest fork
Approved
My code passes all tests except one, but I believe this is true.
"8.015856437398833 should equal 8.015856437398835." This is an error on the second check
What should I do to pass the kata?
OP solved it, closing
JS: function and parameter name should use
camelCase
C#:
Method name should be
PascalCase
(Please refer to implementation of backward compatibility here )Floating point comparison should be used in assertions instead of rounding both actual and expected results
14.3259057835044 should equal 14.325905783504401
7.733044285559698 should equal 7.7330442855597
all other tests passed (python)
This comment is hidden because it contains spoiler information about the solution
The statistics module doesn't accept non-positive (zero and negative numbers). It also performs operation on floats and doesn't guarantee exact results. See here.
i tried just using the statistics module, I don't know why it failed
I was able to provide solution for the basic test and random tests but the extended test was given me this error: Test Failed
Expected: 7.7330442855596999d
But was: 6.8737933528262785d
What could be the probable C# solutions?, i tried some Math methods like Floor(), Ceiling(), Abs(), Round() already.
Thank you
I guess this year's Christmas miracle is this kata finally getting fixed.
Read the error message. It tells you exactly what's wrong, and it's in your code, not the tests.
Did you know there's a Troubleshooting Guide in the Docs?
This comment is hidden because it contains spoiler information about the solution
Loading more items...