Circles Relationship
Problem statement
Two circles on a Cartesian plane, A and B, are each defined by three descriptors:
- x: the x-coordinate of the circle's center
- y: the y-coordinate of the circle's center
- R: the radius of the circle
Circles A and B will both be centered either on the X-axis (i.e., YA = 0 and YB = 0, or on the Y-axis (i.e., XA = 0 and XB = 0), but not both.
A pair of circles (A and B) will have one of the following relationship types:
- Touching: they touch each other at a single point
- Concentric: they have the same center point
- Intersecting: they intersect each other (touching at two points)
- Disjoint-Outside: disjoint with one not existing outside of the other
- Disjoint-Inside: disjoint with one contained inside the other (but not concentric)
Function
circles(circlePairs: String[]) → String[]
Complete the function circles in the editor.
circles has the following parameter(s):
string circlePairs[n]: each string contains six space-separated integers. The first three integers are X, Y, and R for circle A, and the last three are X, Y, and R for circle B.
Returns
string[n]: each string is the relation between the circles described in circlePairs[i]
Examples
Example 1
circlePairs = ["3 0 10 5 0 3", "0 1 4 0 1 5"]return = ["Disjoint-Inside", "Concentric"]- The circles are Disjoint-Inside.
- Circle A is centered at (3, 0) and extends 10 units along the x-axis from -7 to 13.
- Circle B is centered at (5, 0) and extends 3 units along the x-axis from 2 to 8.
- The circles are Concentric.
- Circle A is centered at (0, 1) and extends 4 units along the y-axis from -3 to 5.
- Circle B is centered at (0, 1) and extends 5 units along the y-axis from -4 to 6.
Constraints
- 1 ≤ n ≤ 5000
- 0 ≤ X,Y,R ≤ 5000