7 kyu
Point in a unit circle
696 of 2,233kimduy91
Loading description...
Mathematics
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.
C translation (author gone)
Approved
COBOL translation (author inactive).
approved
This comment has been hidden.
This only checks the sides. What about, for example, a point at x = 0.9, y = 0.9 ? It's clearly outside the circle, but your code returns true.
TypeScript translation
Approved
This is no way seven kyu.
This kata is 4 years old so no chance to change that.
Just out of curiousity, would you have given it 6 or 8?
Not tested in Python.
Not tested anywhere because of this comment https://www.codewars.com/kata/58da7ae9b340a2440500009c/discuss#6052a73909032000440076dd
This is a bad answer, as demonstrated by Chrono79.
So should we add border tests? General tests with random
x
and the correspondingy
on the border are really bad because they are likely to give wrong results. There are some test values which I consider "safe" (pythagorean triplets) as the standard approaches give the correct result.My vote is yes, but with only those 4 coordinates I suggested. About the other random tests, ideally, they should fall 50% inside and 50% outside.
Ok, I added the 4 axis points to the fixed/basic tests of the current languages.
There is a bug in the sample test cases for the python language version 3.8! Last test case (0.71, 0.71) should be inside the circle, but the output is giving False.
The problem is
@test.it("(0.71, 0.71) is inside")
should be@test.it("(0.71, 0.71) is outside")
because the point is indeed outside.So could you please fix this issue?
Not yet, maybe natan can. For me to fix it, we'll have to wait a week until edit button appears.
Ok, thank you!
Fixed.
Java translation
Approved by someone
Boundary cases are mentionned in the description but are not tested. Description should be updated.
Please no.
That will only lead to problems with floating point representation inaccuracy.
Please keep testing well away from the boundary.
So description should be coherent and state this boundary case won't be tested.
There are at least 4 tests cases that don't need to handle floating point numbers: (-1, 0), (0, -1), (0, 1) and (1, 0). They should be added.
This comment has been hidden.
This comment has been hidden.
Are you testing points on the boundary return false? Otherwise the note about the open disk is not relevant.
No. Someone changed that note. The original note was "The given point will be never on the circle.", so I didn't test points on the boundary.
Your Kata needs more extensive test coverage to prevent easy cheap-cheat solutions and/or logically flawed solutions. The most common way to increase test coverage is through the inclusion of randomly generated test cases at runtime so please add these. The lack of test coverage in a Kata as an Issue is recognised as an official CW stance.
I added some random test cases. Is it okay now or should I add more of these?
This comment has been hidden.
I take every critic seriously :) I increased the random tests to 10. Do you happen to know, how I can add these random tests more efficiently? Right now, I have to copy my function into the test case for each random test and it could be quite labor intensive for 100+ random tests.
This comment has been hidden.
So I can do something like that. Thanks!