5 kyu
Closest Neighbouring Points I
125 of 146raulbc777
Loading description...
Fundamentals
Mathematics
Data Structures
Algorithms
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.
How can you know the order required?? My solutions are identical, the points are just ordered differently.
python new test framework is required. updated in this fork
Approved!
Description should be language-agnostic
Ruby
3.0 should be enabled with unnecessary logs removed
Parameter name should be snake_case
Python
New test framework should be used with unnecessary logs removed
Parameter name should be snake_case
done.
Your code should be able to process lists of points up to 1000 length in the allowed runtime for tests.
But Python tests up to
700
while Ruby tests up to400
Python 3 should be enabled.
Done.
This comment has been hidden.
Fixed (I blame it on CW notifications for not notifying me 5 months ago)
This comment has been hidden.
Re-posting it as an issue for more visibility.
Even although the first sentence calls for an accurate solution, many current solutions, including the one with most "best practices" upvotes (4), will fail the following test case, which I think should be added to rule out the not-quite-right solutions:
I similarly was annoyed that we had to round the distance. I ran into a weird problem using int() vs round().
from math import sqrt
r2 = 5
rA = int( sqrt(r2)*10000 )/10000 # 2.236
rB = round( r2**0.5, 4 ) # 2.236
This happened ONLY when r-squared equalled 5.
Approved
This comment has been hidden.
Minor description rewrite, fixed a spelling mistake, changed name of variable to list_points and added some spacing for readability:
Description:
We need a function, closest_points() that may give an accurate result to find the closest pair or pairs of points that are contained in square areas of size l. The function will receive a list of variable number of points in a list (each point represented with cartesian coordinates) and should display the results in the following way [(1), (2), (3)]
(1) - Number of points received
(2) - Pair or pairs of closest points in a sorted list of tuples (each tuple having the cartesian coordinates (x, y) of the encountered closest points)
(3) - the distance of this pair or these pairs of found closes points, that is the minimal distance between every possible pair of the given of points. This value will be expressed as a float with at most, 4 decimal digits (rounded result).
Let's see some cases.
Your code should be able to process lists of points up to 1000 length in the allowed runtime for tests.
Happy coding!!
Zebulan, thank you for your help to improve this kata. I've studied all the changes that you suggested and I've done a copy paste and edited the kata according to your kind and excellent contribution. Also I changed the name of the variables to list_pointsI and lis_pointsII in the example tests. Your good suggestions are welcome.
No problem, I'm just trying to help. I don't have much of a background with mathematics so I enjoy your katas a lot, even though I cannot complete them all... yet!