← Back to challenges

Points on Rectangle Bounds

PythonHardmatharrays

Instructions

Given a list of 2D points [x, y], create a function that returns True if those points can be on the bounds of a rectangle, False otherwise.

Examples

on_rectangle_bounds([[0, 1], [1, 0], [1, 1], [0, 0]]) ➞ True

on_rectangle_bounds([[0, 1], [1, 0], [1, 1], [0.5, 0.5]]) ➞ False

on_rectangle_bounds([[0, 1], [10, 0], [10, 1]]) ➞ True

on_rectangle_bounds([[0, 1]]) ➞ True

Notes

Only rectangles with sides parallel to x-axis and y-axis will be considered.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.