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.
python new test framework is required. updated in this fork
This comment is hidden because it contains spoiler information about the solution
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.