Points on Rectangle Bounds

Published by xAlien95 in

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.

Watch a quick demo on how Edabit works.