human
What is a code to count distinct elements in an array and the other steps required given the following:
Count distinct elements in an array | Python3 program to count distinct elements in a given array.
Pick all elements one by one.
If not printed earlier , then print it.
Driver Code"
Solution in Python:
assistant
#Here is code to count distinct elements in an array and the other steps required.
 def countDistinct ( arr , n ) :
	res = 1
	for i in range ( 1 , n ) :
		j = 0
		for j in range ( i ) :
			if ( arr [ i ] == arr [ j ] ) :
				break
		if ( i == j + 1 ) :
			res += 1
	return res
arr = [ 12 , 10 , 9 , 45 , 2 , 10 , 10 , 45 ]
n = len ( arr )
print ( countDistinct ( arr , n ) )