Ad
  • Custom User Avatar

    As per my comment below, the handling of uncertainty in this kata is pretty weird. Solutions are required to deliver answers with higher precision than the inputs, and therefore coders must either:

    1. Think about the numerical analysis of their solution (not really a 7-kyu thing)
    2. Fiddle around with the algebra until they stumble on a correct solution or get lucky with the random tests (not great for learning IMO)

    For reference the uncertainty on the volume of a sphere with radius 1000+-0.005 (rounded to 2DP as in this kata) is about +-157, whereas the kata asks for an answer accurate to +-0.000005

    I suggest one of the following be applied:

    1. Test answers to within a percentage of the expected value rather than to a static 5DP; Gaussian error approximation for the most complex of these calculations is about 0.03%, which would prevent most issues.
    2. The description be updated to mention the need for accuracy, and some hints about how to do that (e.g. avoid rounding on intermediate values) could be added.
  • Custom User Avatar

    I'm a little torn on this one. Inputs are at 2DP, and there are two possible interpretations of that:

    1. Inputs are exact 2DP numbers, and are therefore perfectly precise
    2. Inputs are inexact and rounded to 2DP, and are therefore precise to +-0.005 units

    In the first interpretation, your solution is incorrect if it disagrees with the test results. You can verify this by being as precise as possible with your calculations, using rational numbers only in a fractional representation (therefore perfect precision) for all intermediate calculations, and introducing pi (irrational) only directly before rounding and returning your result. If you do this you'll see that none of the tests fail, and therefore other failures using floating point must be due to unnecessary error propagation - technically speaking that's a bug in your code and not a kata issue.

    In the second interpretation, however, it's the tests that are wrong to expect 5DP precision. You cannot take two inexact values and produce an output that is more precise.

    Given the kata is 7-kyu I lean toward the second option; tests should be rounded to at most the precision of the inputs. Correctly solving the first interpretation requires some knowledge of numerical analysis and error propagation which exceeds the intended difficulty of the kata, even though with a bit of fiddling most people would get it "correct" eventually. Adding this as a suggestion to the kata.

  • Custom User Avatar

    The "issue" tag is for problems with the kata, not problems you're having solving it. This is a problem in your code. Please use the "question" tag instead in the future unless you're very, very certain that the kata itself is broken.

    In either case please provide more information. "Doesn't work" isn't enough info to help you with either kata issues or questions. What are you seeing, and how does it differ from what you expect? Remember to also use a spoiler tag if you're posting complete or partial solutions.

  • Default User Avatar

    that's a bold statement. can you prove it?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution