Points on Rectangle Bounds

Published by xAlien95 in

Given an array 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

onRectangleBounds([[0, 1], [1, 0], [1, 1], [0, 0]]) ➞ true

onRectangleBounds([[0, 1], [1, 0], [1, 1], [0.5, 0.5]]) ➞ false

onRectangleBounds([[0, 1], [10, 0], [10, 1]]) ➞ true

onRectangleBounds([[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.