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.
python new test framework is required. updated in this fork
Python: Random tests are vulnerable to input modification
The rounding requirements are horrible. We have to guess the author's algorithm and intermediate steps where rounding is expected. This takes away all the fun and quality of the kata. Big thumbs down from me.
I'm still having difficulty with rounding errors. Best policy for katas is not to round results before comparison, but to use a proper fuzzy comparison with an appropriate margin of tolerance, such as with the test framework routine named
assertApproxEquals
or something similar. Rounding has the potential to magnify an error if it happens to be close to the split between rounding up and rounding down and the reference solution goes one direction while the user's solution goes the other way even though their absolute difference may be very small. See https://docs.codewars.com/authoring/recipes/floating-point/ for more information about best practices when dealing with floating point numbers.Done.
Python 3 should be enabled.
Thank you
It's already explained just below.
This is an excellent solution. How did you come up with this logic? I don't understand the formula. Can you please explain me?
Where did you get this formula from please?
Rational numbers need not have numerical imprecision.
This does require arbitrary precision integers though, which JS did not have at the time, and
Rational
is not a native JS datatype even now - though it can be constructed quite easily. But e.g. Haskell has exactRational
s natively.Haskell translation
This comment is hidden because it contains spoiler information about the solution
Good points. I have included links for interpolation methods (although the Bernstein Form might not be relevant for this kata, I'll review that some more) and reworked my examples. What do you think of these updates?
This kata does combine two concepts, and perhaps it would be better to separate them into individual katas; namely, "interpolation" over an integer-valued polynomial, and "representation" of an integer-valued polynomial. In this case, the two concepts are closely tied, since (as described) a standard-form polynomial (like 0.5 x2 + 0.5 x) can be integer-valued without having integer coefficients, while a Binomial form polynomial is integer-valued if and only if it has integer coefficients.
Loading more items...