7 kyu
Building Spheres
2,242 of 2,988NaMe613
Loading description...
Object-oriented Programming
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
python new test framework
Approved
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:
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:
This comment has been hidden.
that's a bold statement. can you prove it?
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.
Test cases marked as True or as False by a few decimals points, depending on whether some multiplication is put first or last. That is a serious bug. Test should not exactly compare floats !
Yup, went the same way for me. I was off by a tiny bit and had to play around to find the "right" order
I'm a little torn on this one. Inputs are at 2DP, and there are two possible interpretations of that:
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.
Rust translation.
That's not how Python classes are supposed to work... There is no point in point in implementing
get_mass
when you can already use the attribute.mass
. And even the three that are not direct attributes should use @property instead of a method.This comment has been hidden.
Instruction text should provide formulas needed and test failures should state which test failed with what input data.
It's never been the case that the instructions for Codewars Kata should include common formulas.
Suggestion
What is the Sphere is created with a mass/radius with greater that 5 digits of percision? Should the getters round those too?
Not an issue, a question. Even if a good one. Currently, the raidus isn't rounded. But the inputs have never more than 5 digits precision?
This comment has been hidden.
This comment has been hidden.
The problem lays elsewhere. With correct implementation, according to the python version, methods are reusable.
This comment has been hidden.
This comment has been hidden.
tests need more constructive feedback, if testing only programming skills then formula for sphere should be supplied
done
You need to use some fuzz when comparing values in Python. It took me longer to figure out exactly why my answers were off by 0.00001 then it took to write the code in the first place. Rounding differences between multiplying first and then dividing vs. dividing first and then multiplying.