Relationship between rectangles X87831


Statement
 

pdf   zip

Using the definitions

class Point:
    """attributes: x, y"""

class Rectangle:
    """attributes: width, height, corner"""

write a function

relationship_between_rectangles(r1, r2)

that returns @less than@ if @r1@ is inside @r2@, @greater than@ if @r2@ is inside @r1@, @overlap@ if @r1@ and @r2@ overlap, @equal@ if @r1@ and @r2@ are identical, and @disjoint@ otherwise (if @r1@ and @r2@ do not share any point).

Input

The input consists of several pairs of rectangles (four non-negative integer numbers for each: the width, the height, and the coordinates of the lower-left corner).

Output

For each pair of rectangles, print their relationship as shown below.

Public test cases
  • Input

    2 1 2 1    6 3 0 0
    6 3 0 0    6 3 0 0
    6 3 0 0    2 1 2 1
    6 3 0 0    6 3 2 1
    6 3 0 0    6 3 6 3
    2 1 0 0    6 3 0 0
    6 3 0 0    2 1 6 0
    6 3 0 0    2 1 0 3
    6 3 0 0    2 1 8 0
    6 3 0 0    2 1 0 4
    

    Output

    less than
    equal
    greater than
    overlap
    overlap
    overlap
    overlap
    overlap
    disjoint
    disjoint
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    Python
    User solutions
    Python