human
Count of index pairs with equal elements in an array | Return the number of pairs with equal values ..
for each index i and j.
finding the index with same value but different index ..
Driven Code"
How can the above be solved in Python?
 ... Can you provide a code to count of index pairs with equal elements in an array and the other steps required?
assistant
#Here is code to count of index pairs with equal elements in an array and the other steps required.
 def countPairs ( arr , n ) :
	ans = 0
	for i in range ( 0 , n ) :
		for j in range ( i + 1 , n ) :
			if ( arr [ i ] == arr [ j ] ) :
				ans += 1
	return ans
arr = [ 1 , 1 , 2 ]
n = len ( arr )
print ( countPairs ( arr , n ) )