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.
Being not able to fix the rounding error in a solution is not a kata issue.
Expected: 702912415374435841
But was: 702912415374435840
How am I supposed to fix the rounding error?
Nice excercise
Could you link to an example that is passing despite not being "float proof"? The top C# answer by g964 seems to be float proof. It correctly returns -1 for 4503599627370497 and correctly returns 67108865 for custom test case 4503599761588225 (which is greater than floating point precision 2^52 = 4503599627370496) (I did my math through wolframalpha which is more precise than Google's calculator).
C# does not lack precision to solve this test, and any problems with precision are introduced by a buggy solution, not by tests.
For
4503599627370497
, expeced answer is -1, because it is not a perfect square (but4503599627370496
is).For
4503599627370495
, expeced answer is -1, because it is not a perfect square (but4503599627370496
is).Solutions which cannot handle these inputs are buggy and need to be fixed, it is not a problem with tests.
Running into something similar for the test case of 4503599627370495
This comment is hidden because it contains spoiler information about the solution
The tests in C# are way beyond 7 Kyu
I very much agree, this is way harder than any other 7 Kyu I've ever seen
4503599627370497 is too large a number for double-precision math, meaning it gets rounded down to 4503599627370496 before the square root is found, which is a perfect square. This is way beyond a 7 Kyu exercise
In such case,
67,108,864 ** 2
should end with the digit 6, wouldn't it?I used https://www.gigacalculator.com/calculators/square-root-calculator.php and calculator app by Google. Both gave me a whole number which was 67,108,864. The google calculator gave me specifically 67,108,864.000000
I am not sure how you checked it, but square root of
4503599627370497
is not a whole number.Anyone know what is wrong with the arugment being 4503599627370497? I checked and I got a whole number as the square root yet its telling me that I need to return -1.
this was a good one :)
Loading more items...