Post History
Given 3 points, output one that is separated from its nearest neighbour by the largest distance. Input 3 distinct points (that is, no 2 points are in the same position). Each point is a pair o...
#2: Post edited
- Given 3 points, output one that is separated from its nearest neighbour by the largest distance.
- ## Input
- - 3 distinct points (that is, no 2 points are in the same position).
- - Each point is a pair of positive integers.
- ## Output
- - A single point, as a pair of positive integers.
- - The distance between this point and its nearest neighbour must be greater than or equal to the distance from either of the other points to their nearest neighbour.
- - If all 3 of the input points have this property[^1], you may output any of them, but you must output only 1 of them.
- ## Examples
- ### Example with a single valid output
- Input points and distance to nearest neighbour:
- ```text
- 1,3 : 1.4142135
- 2,2 : 1.0000000
- 3,2 : 1.0000000
- ```
- Output:
- ```text
- 1,3
- ```
- ### Example with three valid outputs
- Input points and distance to nearest neighbour:
- ```text
- 6,5 : 3.6055512
- 4,2 : 3.6055512
- 9,3 : 3.6055512
- ```
- All the nearest neighbour distances are the same, so any 1 of the following is a valid output:
- ```text
- 6,5
- 4,2
- 9,3
- ```
- ## Test cases
- Note that if there is more than 1 valid output, you must output only 1 of them.
- Test case are in the format `inputs : outputs`.- - Inputs are in the format `point1 ; point2 ; point3`.
- - Outputs are in the format `point1 | point2 | point3`.
- - Points are in the format `x,y`.
- ```text
- 3,3 ; 1,1 ; 3,1 : 3,3 | 1,1 | 3,1
- 3,3 ; 1,1 ; 2,2 : 3,3 | 1,1 | 2,2
- 3,1 ; 3,3 ; 2,2 : 3,1 | 3,3 | 2,2
- 1,3 ; 2,2 ; 3,2 : 1,3
- 3,2 ; 1,1 ; 3,1 : 1,1
- 9,1 ; 8,5 ; 5,4 : 9,1
- 3,2 ; 7,7 ; 3,1 : 7,7
- 6,5 ; 4,2 ; 9,3 : 6,5 | 4,2 | 9,3
- 1,9 ; 8,2 ; 6,9 : 8,2
- 9,8 ; 6,7 ; 5,9 : 9,8
- 2,4 ; 7,5 ; 1,7 : 7,5
- 9,6 ; 5,7 ; 5,4 : 9,6
- 9,6 ; 6,1 ; 9,4 : 6,1
- 7,9 ; 2,5 ; 2,2 : 7,9
- 6,8 ; 9,1 ; 9,3 : 6,8
- 85,6 ; 64,3 ; 95,19 : 64,3
- 5,24 ; 32,8 ; 74,46 : 74,46
- 36,38 ; 3,25 ; 30,46 : 3,25
- 60,34 ; 97,56 ; 59,86 : 59,86
- 17,49 ; 34,42 ; 20,60 : 34,42
- 14,10 ; 32,10 ; 78,26 : 78,26
- 8,68 ; 26,50 ; 88,74 : 88,74
- 29,82 ; 78,66 ; 1,83 : 78,66
- 51,65 ; 90,54 ; 66,8 : 66,8
- 80,28 ; 38,92 ; 73,85 : 80,28
- 31,97 ; 11,20 ; 19,57 : 31,97
- 83,45 ; 96,16 ; 16,97 : 16,97
- 95,59 ; 32,87 ; 57,90 : 95,59
- 17,33 ; 1,3 ; 45,20 : 1,3
- 11,16 ; 79,22 ; 84,6 : 11,16
- 36,9 ; 89,49 ; 45,78 : 36,9
- 8,53 ; 42,51 ; 28,78 : 8,53
- 77,21 ; 44,38 ; 84,20 : 44,38
- 66,58 ; 76,13 ; 67,84 : 76,13
- 76,45 ; 22,46 ; 33,74 : 76,45
- ```
- ## Scoring
- This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
- > Explanations are optional, but I'm more likely to upvote answers that have one.
- [^1]: It is not possible for exactly 2 of the input points to have this property. There will either be exactly 1 or exactly 3.
- [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
- Given 3 points, output one that is separated from its nearest neighbour by the largest distance.
- ## Input
- - 3 distinct points (that is, no 2 points are in the same position).
- - Each point is a pair of positive integers.
- ## Output
- - A single point, as a pair of positive integers.
- - The distance between this point and its nearest neighbour must be greater than or equal to the distance from either of the other points to their nearest neighbour.
- - If all 3 of the input points have this property[^1], you may output any of them, but you must output only 1 of them.
- ## Examples
- ### Example with a single valid output
- Input points and distance to nearest neighbour:
- ```text
- 1,3 : 1.4142135
- 2,2 : 1.0000000
- 3,2 : 1.0000000
- ```
- Output:
- ```text
- 1,3
- ```
- ### Example with three valid outputs
- Input points and distance to nearest neighbour:
- ```text
- 6,5 : 3.6055512
- 4,2 : 3.6055512
- 9,3 : 3.6055512
- ```
- All the nearest neighbour distances are the same, so any 1 of the following is a valid output:
- ```text
- 6,5
- 4,2
- 9,3
- ```
- ## Test cases
- Note that if there is more than 1 valid output, you must output only 1 of them.
- - Test cases are in the format `inputs : outputs`.
- - Inputs are in the format `point1 ; point2 ; point3`.
- - Outputs are in the format `point1 | point2 | point3`.
- - Points are in the format `x,y`.
- ```text
- 3,3 ; 1,1 ; 3,1 : 3,3 | 1,1 | 3,1
- 3,3 ; 1,1 ; 2,2 : 3,3 | 1,1 | 2,2
- 3,1 ; 3,3 ; 2,2 : 3,1 | 3,3 | 2,2
- 1,3 ; 2,2 ; 3,2 : 1,3
- 3,2 ; 1,1 ; 3,1 : 1,1
- 9,1 ; 8,5 ; 5,4 : 9,1
- 3,2 ; 7,7 ; 3,1 : 7,7
- 6,5 ; 4,2 ; 9,3 : 6,5 | 4,2 | 9,3
- 1,9 ; 8,2 ; 6,9 : 8,2
- 9,8 ; 6,7 ; 5,9 : 9,8
- 2,4 ; 7,5 ; 1,7 : 7,5
- 9,6 ; 5,7 ; 5,4 : 9,6
- 9,6 ; 6,1 ; 9,4 : 6,1
- 7,9 ; 2,5 ; 2,2 : 7,9
- 6,8 ; 9,1 ; 9,3 : 6,8
- 85,6 ; 64,3 ; 95,19 : 64,3
- 5,24 ; 32,8 ; 74,46 : 74,46
- 36,38 ; 3,25 ; 30,46 : 3,25
- 60,34 ; 97,56 ; 59,86 : 59,86
- 17,49 ; 34,42 ; 20,60 : 34,42
- 14,10 ; 32,10 ; 78,26 : 78,26
- 8,68 ; 26,50 ; 88,74 : 88,74
- 29,82 ; 78,66 ; 1,83 : 78,66
- 51,65 ; 90,54 ; 66,8 : 66,8
- 80,28 ; 38,92 ; 73,85 : 80,28
- 31,97 ; 11,20 ; 19,57 : 31,97
- 83,45 ; 96,16 ; 16,97 : 16,97
- 95,59 ; 32,87 ; 57,90 : 95,59
- 17,33 ; 1,3 ; 45,20 : 1,3
- 11,16 ; 79,22 ; 84,6 : 11,16
- 36,9 ; 89,49 ; 45,78 : 36,9
- 8,53 ; 42,51 ; 28,78 : 8,53
- 77,21 ; 44,38 ; 84,20 : 44,38
- 66,58 ; 76,13 ; 67,84 : 76,13
- 76,45 ; 22,46 ; 33,74 : 76,45
- ```
- ## Scoring
- This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
- > Explanations are optional, but I'm more likely to upvote answers that have one.
- [^1]: It is not possible for exactly 2 of the input points to have this property. There will either be exactly 1 or exactly 3.
- [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
#1: Initial revision
Most isolated of 3 points
Given 3 points, output one that is separated from its nearest neighbour by the largest distance. ## Input - 3 distinct points (that is, no 2 points are in the same position). - Each point is a pair of positive integers. ## Output - A single point, as a pair of positive integers. - The distance between this point and its nearest neighbour must be greater than or equal to the distance from either of the other points to their nearest neighbour. - If all 3 of the input points have this property[^1], you may output any of them, but you must output only 1 of them. ## Examples ### Example with a single valid output Input points and distance to nearest neighbour: ```text 1,3 : 1.4142135 2,2 : 1.0000000 3,2 : 1.0000000 ``` Output: ```text 1,3 ``` ### Example with three valid outputs Input points and distance to nearest neighbour: ```text 6,5 : 3.6055512 4,2 : 3.6055512 9,3 : 3.6055512 ``` All the nearest neighbour distances are the same, so any 1 of the following is a valid output: ```text 6,5 4,2 9,3 ``` ## Test cases Note that if there is more than 1 valid output, you must output only 1 of them. - Test case are in the format `inputs : outputs`. - Inputs are in the format `point1 ; point2 ; point3`. - Outputs are in the format `point1 | point2 | point3`. - Points are in the format `x,y`. ```text 3,3 ; 1,1 ; 3,1 : 3,3 | 1,1 | 3,1 3,3 ; 1,1 ; 2,2 : 3,3 | 1,1 | 2,2 3,1 ; 3,3 ; 2,2 : 3,1 | 3,3 | 2,2 1,3 ; 2,2 ; 3,2 : 1,3 3,2 ; 1,1 ; 3,1 : 1,1 9,1 ; 8,5 ; 5,4 : 9,1 3,2 ; 7,7 ; 3,1 : 7,7 6,5 ; 4,2 ; 9,3 : 6,5 | 4,2 | 9,3 1,9 ; 8,2 ; 6,9 : 8,2 9,8 ; 6,7 ; 5,9 : 9,8 2,4 ; 7,5 ; 1,7 : 7,5 9,6 ; 5,7 ; 5,4 : 9,6 9,6 ; 6,1 ; 9,4 : 6,1 7,9 ; 2,5 ; 2,2 : 7,9 6,8 ; 9,1 ; 9,3 : 6,8 85,6 ; 64,3 ; 95,19 : 64,3 5,24 ; 32,8 ; 74,46 : 74,46 36,38 ; 3,25 ; 30,46 : 3,25 60,34 ; 97,56 ; 59,86 : 59,86 17,49 ; 34,42 ; 20,60 : 34,42 14,10 ; 32,10 ; 78,26 : 78,26 8,68 ; 26,50 ; 88,74 : 88,74 29,82 ; 78,66 ; 1,83 : 78,66 51,65 ; 90,54 ; 66,8 : 66,8 80,28 ; 38,92 ; 73,85 : 80,28 31,97 ; 11,20 ; 19,57 : 31,97 83,45 ; 96,16 ; 16,97 : 16,97 95,59 ; 32,87 ; 57,90 : 95,59 17,33 ; 1,3 ; 45,20 : 1,3 11,16 ; 79,22 ; 84,6 : 11,16 36,9 ; 89,49 ; 45,78 : 36,9 8,53 ; 42,51 ; 28,78 : 8,53 77,21 ; 44,38 ; 84,20 : 44,38 66,58 ; 76,13 ; 67,84 : 76,13 76,45 ; 22,46 ; 33,74 : 76,45 ``` ## Scoring This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins. > Explanations are optional, but I'm more likely to upvote answers that have one. [^1]: It is not possible for exactly 2 of the input points to have this property. There will either be exactly 1 or exactly 3. [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"