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)
-------------------------
(0,0) (1,0,1)
(1,1) (0,1,1)
Fewest bytes wins.