Boxes and Holes
View as PDFYou are given 2 objects, and you're trying to figure out collisions!
You might be given 2 rectangles, and you want to know if the rectangles overlap or not.
You might also be given 2 circles, and you want to know if the circles overlap or not.
Constraints
Input Specifications
The first line of input will be a string that is either circle or rectangle.
If the first line is circle, there will be 2 lines of input, with each line containing space-separated integers , a circle with center
and radius
.
If the first line is rectangle, there will be 2 lines of input, with each line containing space-separated integers , a rectangle with bottome left corner
, length (horizontally)
and width (vertically)
.
Output Specifications
If the first line of input is circle, output overlapping if the circles overlap (including tangency!), or non-overlapping if the circles are not overlapping.
If the first line of input is rectangle, output overlapping if the rectangles overlap (including touching on the edges or corners!), or non-overlapping if the rectangles are not intersecting.
Sample Input 1
circle
0 0 5
6 8 5
Sample Output 1
overlapping
Explanation for Sample Output 1
It can be shown that the only point where these circles intersect is at . Thus, the two circles are intersecting.
Sample Input 2
rectangle
0 0 2 2
2 2 4 4
Sample Output 2
overlapping
Explanation for Sample Output 2
It can be shown that the only point where these rectangles intersect is at . Thus, the two rectangles are intersecting.
Comments