beacons, where beacons[i] = [x, y]; all points are distinct.
Call a triple of beacons (a, b, c) equidistant if a, b and c are three different beacons and the distance from a to b equals the distance from a to c. Order matters: (a, b, c) and (a, c, b) are different triples.
Return the number of equidistant triples.beacons=[[0, 0], [2, 0], [0, 2]] → 2
Beacons (2, 0) and (0, 2) are both at distance 2 from (0, 0). That gives the triples ((0,0), (2,0), (0,2)) and ((0,0), (0,2), (2,0)). There are no others.
beacons=[[0, 0], [1, 0], [-1, 0], [0, 1]] → 8
Around (0, 0) three beacons are at distance 1, giving 3·2 = 6 ordered triples. Around (0, 1) the beacons (1, 0) and (-1, 0) are both √2 away, giving 2 more. 8 in total.
beacons=[[5, 5]] → 0
A single beacon forms no triples.
beacons=[[0, 0], [2, 0], [0, 2]]
2
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.