a, b, c and d, each given as [x, y]. The pins are listed in arbitrary order, not necessarily the order you would walk around the shape.
Return True if the pins sit at the corners of a square and False otherwise. A square has four equal sides of positive length and four right angles; its sides do not have to be parallel to the axes.a=[2, 0], b=[0, 1], c=[3, 2], d=[1, 3] → True
All sides have length √5 and both diagonals have length √10: it is a square tilted relative to the axes.
a=[0, 0], b=[2, 0], c=[2, 1], d=[0, 1] → False
A 2 by 1 rectangle: the angles are right, but the sides differ.
a=[5, 5], b=[5, 5], c=[5, 5], d=[5, 5] → False
All pins share one spot, and a square needs sides of positive length.
a.length = b.length = c.length = d.length = 2a=[2, 0], b=[0, 1], c=[3, 2], d=[1, 3]
True
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.