Point in rectangle X53379


Statement
 

pdf   zip

html

Using the definitions

class Point: """attributes: x, y""" class Rectangle: """attributes: width, height, corner"""

write a function

point_in_rectangle(p, r)

that returns inside if a point p is inside a rectangle r, border if p lies on the boundary of r, and outside if p is outside r. For example, the point (50, 100) is inside a rectangle of width 100, height 200, and lower-left corner (0, 0), the point (100,200) lies on the boundary of the rectangle, and the point (200, 300) is outside the rectangle.

Input

The input consists of several rectangles (four non-negative integer numbers: the width, the height, and the coordinates of the lower-left corner), each followed by a point (two non-negative integer numbers).

Output

For each rectangle and point, print inside, border, or outside according to the point being inside, on the boundary of, or outside the rectangle.

Public test cases
  • Input

    100 200 0 0 50 100
    100 200 0 0 0 0
    100 200 0 0 100 0
    100 200 0 0 0 200
    100 200 0 0 100 200
    100 200 0 0 200 0
    100 200 0 0 0 300
    100 200 0 0 200 300
    

    Output

    inside
    border
    border
    border
    border
    outside
    outside
    outside
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    Python
    User solutions
    C++ Python