human
Count number of triplets with product equal to given number | Function to find the triplet.
Consider all pairs and check for a third number so their product is equal to product.
Check if current pair divides product or not If yes , then search for ( product / li [ i ] * li [ j ] ).
Check if the third number is present in the map and it is not equal to any other two elements and also check if this triplet is not counted already using their indexes.
Driver code"
Solution in Python:
 ... What is a code to count number of triplets with product equal to given number and the other steps required?
assistant
#Here is code to count number of triplets with product equal to given number and the other steps required.
 def countTriplets ( li , product ) :
	flag = 0
	count = 0
	for i in range ( len ( li ) ) :
		if li [ i ] != 0 and product % li [ i ] == 0 :
			for j in range ( i + 1 , len ( li ) ) :
				if li [ j ] != 0 and product % ( li [ j ] * li [ i ] ) == 0 :
					if product // ( li [ j ] * li [ i ] ) in li :
						n = li . index ( product // ( li [ j ] * li [ i ] ) )
						if n > i and n > j :
							flag = 1
							count += 1
	print ( count )
li = [ 1 , 4 , 6 , 2 , 3 , 8 ]
product = 24
countTriplets ( li , product )