human
Count pairs in array such that one element is reverse of another | Function to reverse the digits of the number.
Loop to iterate till the number is greater than 0.
Extract the last digit and keep multiplying it by 10 to get the reverse of the number.
Function to find the pairs from the such that one number is reverse of the other.
Iterate through all pairs.
Increment count if one is the reverse of other.
Driver code"
Solution in Python:
assistant
#Here is code to count pairs in array such that one element is reverse of another and the other steps required.
 def reverse ( num ) :
	rev_num = 0
	while ( num > 0 ) :
		rev_num = rev_num * 10 + num % 10
		num = num // 10
	return rev_num
def countReverse ( arr , n ) :
	res = 0
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			if ( reverse ( arr [ i ] ) == arr [ j ] ) :
				res += 1
	return res
if __name__ == ' _ _ main _ _ ' :
	a = [ 16 , 61 , 12 , 21 , 25 ]
	n = len ( a )
	print ( countReverse ( a , n ) )