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.
Testing expects numerical
NaN
s andInfinity
s, but does not check if normal digits areString
s orNumber
s. It's not specified either.It should be specified ( preferably as
Number
s, though theString
s'-'
and'.'
grate ), and it should be tested.I took out the floating point numbers ( and I fixed the typo in the random test headers ). I did not take out the negative zeroes; you can reverse engineer what is expected from testing.
This still does not make it a well-written or well-designed kata ( which is a shame really ), but at least it's solvable now.
Because the reference solution isn't even arbitrary precision real arithmetic, the answer derived by the reference solution is simply wrong. e.g:
The correct result is
0.25663885990172302292589578160906176584827770888387331907749834099698695209475275668754975679175249426790238934990...
as shown by Wolfram Alpha:http://www.wolframalpha.com/input/?i=1000000000000000+%2F+3896526038118073
Edit: as another demonstration of the incorrect behaviour, I tested some inputs where
a === b
, and the reference solution aren't even giving1.0000...
:Needs tests with large initial dividend and a small divisor. Very large (or small) quotients aren't tested at all.
Since this is a kata about big decimal, the typical stuff should be banned, aka all the ways that can cause
require('bignumber.js')
to work.Also there is no point in identifying
-0
. It's considered practically the same to everything except toObject.is
, and even(-0).toString()
gives0
. It's analogous to saying that allNaN
s are equal, which is absurd, an artifact of IEEE floats standard and not a good practice in any means.There is no point in getting digits below precision of a double, because they aren't even resolvable. Even a change in the tiniest significant bit in the divisor will cause the result to change significantly after the 16th digit (aka
1/Number.MAX_SAFE_INTEGER
).I don't think you really understand the intracacies of arbitrary precision real arithmetic. They simply aren't done this way. To begin with, passing numbers in as floating point values is already a grave mistake. They should be passed in as strings (but then this kata would be a duplicate to https://www.codewars.com/kata/divide-numbers-as-strings).
Random tests section titles has a typo: Things like
-2345658712136251.5 = 7811398559714191 =
should be-2345658712136251.5 / 7811398559714191 =
.Nice kata! Looks like it covers every possible edge case. Got me thinking quite a bit. And more over - this could be a useful function in many other applications!
Thanks
Thanks, by removing the
print
statements, it finally passed. :)The second anti-cheat test rejects a code that contains any of
re
,sys
, orprint
as an identifier (being a substring does not matter).The tests show the input numbers, so you won't need to
print
in order to debug.I'll update the description to make the point clear.
I'm trying to use
Python
to solve this kata. All tests passed except the second test inAnti-cheating checks
which shows thatYou're asking for trouble...
, but I'm not hard coding the answer and the total length of the solution is under 5,000 characters, is this a bug or just my problem?Fixed. Also added info in the description about which characters are allowed.
Using non-capturing groups in js gives the error: Contains illegal characters ...