Smallest Integer Disk

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite
2












This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.



Your input will be a list of points with integer coordinates x and y. You can take this as a list of tuples, a list of lists, or any other way to represent a collection of pairs. x and y will both be (possibly negative) integers. Every point is guaranteed to be unique, and there will be at least one point.



Your output will be a disk in the form of three numbers, X, Y, and R. X, Y, and R are all integers, X and Y represent the disk's center and R represents its radius. The distance between every given point and the center must be less than or equal to R, and there must not exist such a disk with a smaller R that also satisfies this condition.



It is possible that there will be multiple possible solutions for a given input, your code must output at least one of them in this case.



You can use any kinds of geometry builtins your language supports if there are any, and input/output may be through built-in point/disk objects instead of just numbers.



Test Cases



Input (Possible) Output(s)
(x,y) (X,Y,R)
-------------------------
(0,0) (0,0,0)
-------------------------
(0,1) (0,0,1)
(1,0) (1,1,1)
-------------------------
(1,4) (4,4,3)
(3,2)
(4,1)
(4,5)
(5,2)
(7,4)
-------------------------
(-1,0) (0,0,2)
(2,0) (1,0,2)
-------------------------
(-1,0) (1,0,2)
(2,1) (0,1,2)


Fewest bytes wins.










share|improve this question























  • Sandbox
    – Pavel
    2 hours ago










  • Found a couple typos, if you don't mind me pointing them out: "This is made somewhat trickier..."; "...represents the disk's center and R represents its radius..."; "...and there must not exist such a disk..."
    – J. Sallé
    2 hours ago







  • 2




    Usually making things integer just make code-golf easier.
    – user202729
    2 hours ago










  • @KevinCruijssen That's by coincidence. Inputs can be in any order.
    – Pavel
    1 hour ago










  • @Pavel The input can be in any order, or we can take the input in any order? As in, the input can be in any order and we should manually sort first in our solution, or can we already take the input pre-sorted?
    – Kevin Cruijssen
    1 hour ago















up vote
6
down vote

favorite
2












This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.



Your input will be a list of points with integer coordinates x and y. You can take this as a list of tuples, a list of lists, or any other way to represent a collection of pairs. x and y will both be (possibly negative) integers. Every point is guaranteed to be unique, and there will be at least one point.



Your output will be a disk in the form of three numbers, X, Y, and R. X, Y, and R are all integers, X and Y represent the disk's center and R represents its radius. The distance between every given point and the center must be less than or equal to R, and there must not exist such a disk with a smaller R that also satisfies this condition.



It is possible that there will be multiple possible solutions for a given input, your code must output at least one of them in this case.



You can use any kinds of geometry builtins your language supports if there are any, and input/output may be through built-in point/disk objects instead of just numbers.



Test Cases



Input (Possible) Output(s)
(x,y) (X,Y,R)
-------------------------
(0,0) (0,0,0)
-------------------------
(0,1) (0,0,1)
(1,0) (1,1,1)
-------------------------
(1,4) (4,4,3)
(3,2)
(4,1)
(4,5)
(5,2)
(7,4)
-------------------------
(-1,0) (0,0,2)
(2,0) (1,0,2)
-------------------------
(-1,0) (1,0,2)
(2,1) (0,1,2)


Fewest bytes wins.










share|improve this question























  • Sandbox
    – Pavel
    2 hours ago










  • Found a couple typos, if you don't mind me pointing them out: "This is made somewhat trickier..."; "...represents the disk's center and R represents its radius..."; "...and there must not exist such a disk..."
    – J. Sallé
    2 hours ago







  • 2




    Usually making things integer just make code-golf easier.
    – user202729
    2 hours ago










  • @KevinCruijssen That's by coincidence. Inputs can be in any order.
    – Pavel
    1 hour ago










  • @Pavel The input can be in any order, or we can take the input in any order? As in, the input can be in any order and we should manually sort first in our solution, or can we already take the input pre-sorted?
    – Kevin Cruijssen
    1 hour ago













up vote
6
down vote

favorite
2









up vote
6
down vote

favorite
2






2





This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.



Your input will be a list of points with integer coordinates x and y. You can take this as a list of tuples, a list of lists, or any other way to represent a collection of pairs. x and y will both be (possibly negative) integers. Every point is guaranteed to be unique, and there will be at least one point.



Your output will be a disk in the form of three numbers, X, Y, and R. X, Y, and R are all integers, X and Y represent the disk's center and R represents its radius. The distance between every given point and the center must be less than or equal to R, and there must not exist such a disk with a smaller R that also satisfies this condition.



It is possible that there will be multiple possible solutions for a given input, your code must output at least one of them in this case.



You can use any kinds of geometry builtins your language supports if there are any, and input/output may be through built-in point/disk objects instead of just numbers.



Test Cases



Input (Possible) Output(s)
(x,y) (X,Y,R)
-------------------------
(0,0) (0,0,0)
-------------------------
(0,1) (0,0,1)
(1,0) (1,1,1)
-------------------------
(1,4) (4,4,3)
(3,2)
(4,1)
(4,5)
(5,2)
(7,4)
-------------------------
(-1,0) (0,0,2)
(2,0) (1,0,2)
-------------------------
(-1,0) (1,0,2)
(2,1) (0,1,2)


Fewest bytes wins.










share|improve this question















This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.



Your input will be a list of points with integer coordinates x and y. You can take this as a list of tuples, a list of lists, or any other way to represent a collection of pairs. x and y will both be (possibly negative) integers. Every point is guaranteed to be unique, and there will be at least one point.



Your output will be a disk in the form of three numbers, X, Y, and R. X, Y, and R are all integers, X and Y represent the disk's center and R represents its radius. The distance between every given point and the center must be less than or equal to R, and there must not exist such a disk with a smaller R that also satisfies this condition.



It is possible that there will be multiple possible solutions for a given input, your code must output at least one of them in this case.



You can use any kinds of geometry builtins your language supports if there are any, and input/output may be through built-in point/disk objects instead of just numbers.



Test Cases



Input (Possible) Output(s)
(x,y) (X,Y,R)
-------------------------
(0,0) (0,0,0)
-------------------------
(0,1) (0,0,1)
(1,0) (1,1,1)
-------------------------
(1,4) (4,4,3)
(3,2)
(4,1)
(4,5)
(5,2)
(7,4)
-------------------------
(-1,0) (0,0,2)
(2,0) (1,0,2)
-------------------------
(-1,0) (1,0,2)
(2,1) (0,1,2)


Fewest bytes wins.







code-golf geometry






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 2 hours ago









Pavel

4,59613185




4,59613185











  • Sandbox
    – Pavel
    2 hours ago










  • Found a couple typos, if you don't mind me pointing them out: "This is made somewhat trickier..."; "...represents the disk's center and R represents its radius..."; "...and there must not exist such a disk..."
    – J. Sallé
    2 hours ago







  • 2




    Usually making things integer just make code-golf easier.
    – user202729
    2 hours ago










  • @KevinCruijssen That's by coincidence. Inputs can be in any order.
    – Pavel
    1 hour ago










  • @Pavel The input can be in any order, or we can take the input in any order? As in, the input can be in any order and we should manually sort first in our solution, or can we already take the input pre-sorted?
    – Kevin Cruijssen
    1 hour ago

















  • Sandbox
    – Pavel
    2 hours ago










  • Found a couple typos, if you don't mind me pointing them out: "This is made somewhat trickier..."; "...represents the disk's center and R represents its radius..."; "...and there must not exist such a disk..."
    – J. Sallé
    2 hours ago







  • 2




    Usually making things integer just make code-golf easier.
    – user202729
    2 hours ago










  • @KevinCruijssen That's by coincidence. Inputs can be in any order.
    – Pavel
    1 hour ago










  • @Pavel The input can be in any order, or we can take the input in any order? As in, the input can be in any order and we should manually sort first in our solution, or can we already take the input pre-sorted?
    – Kevin Cruijssen
    1 hour ago
















Sandbox
– Pavel
2 hours ago




Sandbox
– Pavel
2 hours ago












Found a couple typos, if you don't mind me pointing them out: "This is made somewhat trickier..."; "...represents the disk's center and R represents its radius..."; "...and there must not exist such a disk..."
– J. Sallé
2 hours ago





Found a couple typos, if you don't mind me pointing them out: "This is made somewhat trickier..."; "...represents the disk's center and R represents its radius..."; "...and there must not exist such a disk..."
– J. Sallé
2 hours ago





2




2




Usually making things integer just make code-golf easier.
– user202729
2 hours ago




Usually making things integer just make code-golf easier.
– user202729
2 hours ago












@KevinCruijssen That's by coincidence. Inputs can be in any order.
– Pavel
1 hour ago




@KevinCruijssen That's by coincidence. Inputs can be in any order.
– Pavel
1 hour ago












@Pavel The input can be in any order, or we can take the input in any order? As in, the input can be in any order and we should manually sort first in our solution, or can we already take the input pre-sorted?
– Kevin Cruijssen
1 hour ago





@Pavel The input can be in any order, or we can take the input in any order? As in, the input can be in any order and we should manually sort first in our solution, or can we already take the input pre-sorted?
– Kevin Cruijssen
1 hour ago











3 Answers
3






active

oldest

votes

















up vote
3
down vote














Jelly, 25 24 22 21 20 18 bytes



«/r»/Œpµ³_²§½ṀĊ,)Ṃ


Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.



Thanks to @Dennis for saving 2 bytes.



Try it online!



Explanation



«/r»/Œpµ³_²§½ṀĊ,)Ṃ Main link. Arg: points
e.g. [[1,4],[3,2],[3,1]]
«/ Find minimums by coordinate
e.g. [1,1]
»/ Find maximums by coordinate
e.g. [3,4]
r Inclusive ranges by coordinate
e.g. [[1,2,3],[1,2,3,4]]
Ã…Â’p Cartesian product of the x and y ranges
e.g. [[1,1],[1,2],[1,3],[1,4],...,[3,4]]
µ Chain, arg: center
e.g. [1,3]
³ Get the original points
e.g. [[1,4],[3,2],[3,1]]
_ Subtract the center from each
e.g. [[0,1],[2,-1],[2,-2]]
² Square each number
e.g. [[0,1],[4,1],[4,4]]
§ Sum each sublist
e.g. [1,5,8]
½ Square root of each number
e.g. [1,2.24,2.83]
Ṁ Find the maximum
e.g. 2.83
Ċ Round up
e.g. 3
, Pair with the center point
e.g. [3,[1,3]]
) Do the above for all points
e.g. [[3,[1,1]],[3,[1,2]],[3,[1,3]],...,[3,[3,4]]]
Ṃ Find the lexicographically smallest pair
e.g. [3,[1,1]]





share|improve this answer






















  • @Dennis Thanks! Since when did Jelly's vectorization repeat the shorter list, or am I misinterpreting the removal of €?
    – Pietu1998
    1 hour ago










  • Depths are matched first. If you a pair and an array of pairs, the pair gets matched with all pairs.
    – Dennis♦
    1 hour ago

















up vote
1
down vote














05AB1E, 26 bytes



øεWsàŸ}`âεUIεX-nOt}àîX‚}н


Port of @Pietu1998's Jelly answer.



Try it online or verify all test cases.



Explanation:





ø # Zip the (implicit) input, swapping the rows and column
# i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
ε # Map each to:
W # Push the smallest value (without popping the list)
# i.e. [[1,3,3],[4,2,1]] → [1,1]
s # Swap so the list is at the top of the stack again
à # Pop the list and push the largest value
# i.e. [[1,3,3],[4,2,1]] → [3,4]
Ÿ # Take the inclusive range of the min and max
# i.e. [[1,2,3],[1,2,3,4]]
` # After the map, push both lists separated to the stack
â # And take the cartesian product of the two lists
# i.e. [[1,2,3],[1,2,3,4]]
# → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
ε } # Map each pair to:
U # Pop and store the current value in variable `X`
I # Push the input
ε } # Map each pair in the input to:
X # Push variable `X`
- # Subtract it from the current pair
# i.e. [3,2] - [1,3] → [2,-1]
n # Take the square of each
# i.e. [2,-1] → [4,1]
O # Sum the lists
# i.e. [4,1] → 5
t # Take the square-root of each
# i.e. 5 → 2.23606797749979
à # Pop the converted list, and push its largest value
# i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
# → [3.0,2.23606797749979,...,3.0]
î # Round it up
# i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
X‚ # Pair it with variable `X`
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
 










up vote
3
down vote














Jelly, 25 24 22 21 20 18 bytes



«/r»/Œpµ³_²§½ṀĊ,)Ṃ


Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.



Thanks to @Dennis for saving 2 bytes.



Try it online!



Explanation



«/r»/Œpµ³_²§½ṀĊ,)Ṃ Main link. Arg: points
e.g. [[1,4],[3,2],[3,1]]
«/ Find minimums by coordinate
e.g. [1,1]
»/ Find maximums by coordinate
e.g. [3,4]
r Inclusive ranges by coordinate
e.g. [[1,2,3],[1,2,3,4]]
Ã…Â’p Cartesian product of the x and y ranges
e.g. [[1,1],[1,2],[1,3],[1,4],...,[3,4]]
µ Chain, arg: center
e.g. [1,3]
³ Get the original points
e.g. [[1,4],[3,2],[3,1]]
_ Subtract the center from each
e.g. [[0,1],[2,-1],[2,-2]]
² Square each number
e.g. [[0,1],[4,1],[4,4]]
§ Sum each sublist
e.g. [1,5,8]
½ Square root of each number
e.g. [1,2.24,2.83]
Ṁ Find the maximum
e.g. 2.83
Ċ Round up
e.g. 3
, Pair with the center point
e.g. [3,[1,3]]
) Do the above for all points
e.g. [[3,[1,1]],[3,[1,2]],[3,[1,3]],...,[3,[3,4]]]
Ṃ Find the lexicographically smallest pair
e.g. [3,[1,1]]





share`âεUIεX-nOt}àîX‚}н


Port of @Pietu1998's Jelly answer.



Try it online or verify all test cases.



Explanation:





ø # Zip the (implicit) input, swapping the rows and column
# i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
ε # Map each to:
W # Push the smallest value (without popping the list)
# i.e. [[1,3,3],[4,2,1]] → [1,1]
s # Swap so the list is at the top of the stack again
à # Pop the list and push the largest value
# i.e. [[1,3,3],[4,2,1]] → [3,4]
Ÿ # Take the inclusive range of the min and max
# i.e. [[1,2,3],[1,2,3,4]]
` # After the map, push both lists separated to the stack
â # And take the cartesian product of the two lists
# i.e. [[1,2,3],[1,2,3,4]]
# → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
ε } # Map each pair to:
U # Pop and store the current value in variable `X`
I # Push the input
ε } # Map each pair in the input to:
X # Push variable `X`
- # Subtract it from the current pair
# i.e. [3,2] - [1,3] → [2,-1]
n # Take the square of each
# i.e. [2,-1] → [4,1]
O # Sum the lists
# i.e. [4,1] → 5
t # Take the square-root of each
# i.e. 5 → 2.23606797749979
à # Pop the converted list, and push its largest value
# i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
# → [3.0,2.23606797749979,...,3.0]
î # Round it up
# i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
X‚ # Pair it with variable `X`
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
 











up vote
1
down vote














05AB1E, 26 bytes



øεWsàŸ`âεUIεX-nOt}àîX‚}н


Port of @Pietu1998's Jelly answer.



Try it online or verify all test cases.



Explanation:





ø # Zip the (implicit) input, swapping the rows and column
# i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
ε # Map each to:
W # Push the smallest value (without popping the list)
# i.e. [[1,3,3],[4,2,1]] → [1,1]
s # Swap so the list is at the top of the stack again
à # Pop the list and push the largest value
# i.e. [[1,3,3],[4,2,1]] → [3,4]
Ÿ # Take the inclusive range of the min and max
# i.e. [[1,2,3],[1,2,3,4]]
` # After the map, push both lists separated to the stack
â # And take the cartesian product of the two lists
# i.e. [[1,2,3],[1,2,3,4]]
# → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
ε } # Map each pair to:
U # Pop and store the current value in variable `X`
I # Push the input
ε } # Map each pair in the input to:
X # Push variable `X`
- # Subtract it from the current pair
# i.e. [3,2] - [1,3] → [2,-1]
n # Take the square of each
# i.e. [2,-1] → [4,1]
O # Sum the lists
# i.e. [4,1] → 5
t # Take the square-root of each
# i.e. 5 → 2.23606797749979
à # Pop the converted list, and push its largest value
# i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
# → [3.0,2.23606797749979,...,3.0]
î # Round it up
# i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
X‚ # Pair it with variable `X`
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
# After the map, sort the list
н # And take the first item (which is output implicitly)
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]] → [3.0,[1,1]]





share`âεUIεX-nOt}àîX‚}н


Port of @Pietu1998's Jelly answer.



Try it online or verify all test cases.



Explanation:





ø # Zip the (implicit) input, swapping the rows and column
# i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
ε # Map each to:
W # Push the smallest value (without popping the list)
# i.e. [[1,3,3],[4,2,1]] → [1,1]
s # Swap so the list is at the top of the stack again
à # Pop the list and push the largest value
# i.e. [[1,3,3],[4,2,1]] → [3,4]
Ÿ # Take the inclusive range of the min and max
# i.e. [[1,2,3],[1,2,3,4]]
` # After the map, push both lists separated to the stack
â # And take the cartesian product of the two lists
# i.e. [[1,2,3],[1,2,3,4]]
# → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
ε } # Map each pair to:
U # Pop and store the current value in variable `X`
I # Push the input
ε } # Map each pair in the input to:
X # Push variable `X`
- # Subtract it from the current pair
# i.e. [3,2] - [1,3] → [2,-1]
n # Take the square of each
# i.e. [2,-1] → [4,1]
O # Sum the lists
# i.e. [4,1] → 5
t # Take the square-root of each
# i.e. 5 → 2.23606797749979
à # Pop the converted list, and push its largest value
# i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
# → [3.0,2.23606797749979,...,3.0]
î # Round it up
# i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
X‚ # Pair it with variable `X`
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
improve this answer













05AB1E, 26 bytes



øεWsàŸ`âεUIεX-nOt}àîX‚}н


Port of @Pietu1998's Jelly answer.



Try it online or verify all test cases.



Explanation:





ø # Zip the (implicit) input, swapping the rows and column
# i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
ε # Map each to:
W # Push the smallest value (without popping the list)
# i.e. [[1,3,3],[4,2,1]] → [1,1]
s # Swap so the list is at the top of the stack again
à # Pop the list and push the largest value
# i.e. [[1,3,3],[4,2,1]] → [3,4]
Ÿ # Take the inclusive range of the min and max
# i.e. [[1,2,3],[1,2,3,4]]
` # After the map, push both lists separated to the stack
â # And take the cartesian product of the two lists
# i.e. [[1,2,3],[1,2,3,4]]
# → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
ε } # Map each pair to:
U # Pop and store the current value in variable `X`
I # Push the input
ε } # Map each pair in the input to:
X # Push variable `X`
- # Subtract it from the current pair
# i.e. [3,2] - [1,3] → [2,-1]
n # Take the square of each
# i.e. [2,-1] → [4,1]
O # Sum the lists
# i.e. [4,1] → 5
t # Take the square-root of each
# i.e. 5 → 2.23606797749979
à # Pop the converted list, and push its largest value
# i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
# → [3.0,2.23606797749979,...,3.0]
î # Round it up
# i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
X‚ # Pair it with variable `X`
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
{ # After the map, sort the list
н # And take the first item (which is output implicitly)
# i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]] → [3.0,[1,1]]






share|improve this answer












share|improve this answer



share|improve this answer










answered 20 mins ago









Kevin Cruijssen

33k554176




33k554176




















      up vote
      0
      down vote













      Javascript, 245 bytes



      a=>[b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);for(f=c;f<b;f++)for(g=e;g<d;g++)s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);n=n?n[2]>s?[f,g,s]:n:[f,g,s]return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]


      (Somewhat) more readable version:



      a=>
      [b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);
      for(f=c;f<b;f++)
      for(g=e;g<d;g++)
      s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);
      n=n?n[2]>s?[f,g,s]:n:[f,g,s]


      return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]



      Just finds the bounding box, and tests each coordinate in that box for whether it's the best.



      I could save 8 bytes with an approximate answer, by replacing:



      Math.ceil(Math.sqrt(n[2])) with ~~(n[2]+1-1e-9)






      share|improve this answer
























        up vote
        0
        down vote













        Javascript, 245 bytes



        a=>[b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);for(f=c;f<b;f++)for(g=e;g<d;g++)s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);n=n?n[2]>s?[f,g,s]:n:[f,g,s]return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]


        (Somewhat) more readable version:



        a=>
        [b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);
        for(f=c;f<b;f++)
        for(g=e;g<d;g++)
        s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);
        n=n?n[2]>s?[f,g,s]:n:[f,g,s]


        return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]



        Just finds the bounding box, and tests each coordinate in that box for whether it's the best.



        I could save 8 bytes with an approximate answer, by replacing:



        Math.ceil(Math.sqrt(n[2])) with ~~(n[2]+1-1e-9)






        share|improve this answer






















          up vote
          0
          down vote










          up vote
          0
          down vote









          Javascript, 245 bytes



          a=>[b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);for(f=c;f<b;f++)for(g=e;g<d;g++)s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);n=n?n[2]>s?[f,g,s]:n:[f,g,s]return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]


          (Somewhat) more readable version:



          a=>
          [b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);
          for(f=c;f<b;f++)
          for(g=e;g<d;g++)
          s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);
          n=n?n[2]>s?[f,g,s]:n:[f,g,s]


          return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]



          Just finds the bounding box, and tests each coordinate in that box for whether it's the best.



          I could save 8 bytes with an approximate answer, by replacing:



          Math.ceil(Math.sqrt(n[2])) with ~~(n[2]+1-1e-9)






          share|improve this answer












          Javascript, 245 bytes



          a=>[b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);for(f=c;f<b;f++)for(g=e;g<d;g++)s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);n=n?n[2]>s?[f,g,s]:n:[f,g,s]return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]


          (Somewhat) more readable version:



          a=>
          [b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);
          for(f=c;f<b;f++)
          for(g=e;g<d;g++)
          s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);
          n=n?n[2]>s?[f,g,s]:n:[f,g,s]


          return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]



          Just finds the bounding box, and tests each coordinate in that box for whether it's the best.



          I could save 8 bytes with an approximate answer, by replacing:



          Math.ceil(Math.sqrt(n[2])) with ~~(n[2]+1-1e-9)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 12 mins ago









          Spitemaster

          1814




          1814



























               

              draft saved


              draft discarded















































               


              draft saved


              draft discarded














              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175405%2fsmallest-integer-disk%23new-answer', 'question_page');

              );

              Post as a guest













































































              Comments

              Popular posts from this blog

              Long meetings (6-7 hours a day): Being “babysat” by supervisor

              Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

              Confectionery