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.
A good kata, but I feel like allowing this is a problem: https://www.codewars.com/kata/reviews/5e36ce74fc5a260001e64e2b/groups/5e47b5b54f4fe30001c2a5d8
Ok so the right value for literal 0.9999 is really -0.00010000500033335.
Thank you to have raised the problem
Do you have a solution for that ? Like using another literal to get -0.00010000500033336 instead ?
The literal
0.9999
in JS represents a 53-significant-bit binary number.https://www.wolframalpha.com/input/?i=ln%280.11111111111110010111001001000111010001010011100011110+base+2%29
Its logarithm is
-0.000100005000333347320819644347167432094870816383142...
If the input is supposed to be decimal for some reason (and it really shouldn't), then it should be a string (no
BigDecimal
in JS).The literal
0.9999
can't mean0.9999
because there would be a contradiction:0.9999 == 0.99990000000000006
and the result for0.99990000000000006
should be the same.Edit: What im saying in this part of the comment is wrong, check the comment below
Voile you are right, ln(0.9999) in this test is false.
But there is a reason...
According to Math.log:
-0.00010000500033334732
According to WolframAlpha: (All decimals are true)
-0.00010000500033335834
So the precision 14 version should be -0.00010000500033336 and not -0.00010000500033335
The Math.log function is false for mantissas near to one.
I think i will set this test to precision 13 only, i will check that.
Edit: -- End of the wrong part --
The newton's method is a good idea
I thought it would not have enough time to execute a million times, what is your advice as a 2 dan, for the kata to be interesting, should I leave the possibility of the Newton method or should i censor it?
Ok i will check that, random tests are 62 random generated bits from 2nd to 62 bit, sign are always positive and first bit is always one.
Is this kind of solution allowed? At least I don't think so.
Sometimes
NaN
is generated in random tests.Thanks again
Looks like it isn't... I don't remember all possibilities, I log objects and look up whenever I need it. The safest way probably would be running user's code in a sandbox, but I'm not even sure how safe it would be.
I patched it
Ok perfect, thank you
I think it was patched, can you tell me if it's effective?
Thanks for helping me find the vulnerabilities, don't hesitate if you have any advice,
I set module.children = undefined; is it sufficient ?
Loading more items...