human
Total number of triplets ( A , B , C ) in which the points B and C are Equidistant to A | Function to count such triplets.
Iterate over all the points.
Iterate over all points other than the current point.
Compute squared euclidean distance for the current point.
Compute nP2 that is n * ( n - 1 ).
Return the final result.
Driver code"
Solution in Python:
assistant
#Here is code to total number of triplets ( A , B , C ) in which the points B and C are Equidistant to A and the other steps required.
 def numTrip ( points ) :
	res = 0
	for i in range ( len ( points ) ) :
		map = { }
		for j in range ( len ( points ) ) :
			if ( j == i ) :
				continue
			dy = points [ i ] [ 1 ] - points [ j ] [ 1 ]
			dx = points [ i ] [ 0 ] - points [ j ] [ 0 ]
			key = dy * dy
			key += dx * dx
			map [ key ] = map . get ( key , 0 ) + 1
		for p in map :
			res += map [ p ] * ( map [ p ] - 1 )
	return res
if __name__ == ' _ _ main _ _ ' :
	mat = [ [ 0 , 0 ] , [ 1 , 0 ] , [ 2 , 0 ] ]
	print ( numTrip ( mat ) )