I am trying to solve a problem of the coding challenge, and the question is described as follows

With N integers A1, A2, …, AN, count the number of triplets (x, y,

z) (with 1≤x <y <z≤N), so that at least one of the following applies

true:

Ax = Ay × Az and / or

Ay = Ax × Az and / or

Az = Ax × Ay

5 2 4 6 3 1

In example case # 1, the only triplet satisfying the condition stated in the problem statement is (2, 4, 5). The triplet is valid because the second, fourth and fifth integers are 2, 6 and 3 and 2 x 3 = 6. So the answer here is **1**

2 4 8 16 32 64

The six triplets fulfilling the condition stated in the problem statement are: (1, 2, 3), (1, 3, 4), (1, 4, 5), (1, 5, 6), (2, 3, 5), (2, 4, 6). The answer here is 6

My code in Python:

```
import itertools
count = 0
for t in itertools.combinations (l, 3):
if t[0]* t[1]== t[2] or t[1]* t[2]== t[0] or t[0]* t[2]== t[1]:
count + = 1
print (count)
```

This is the naive way to create all possible 3 length combinations and to check the condition. This works well for smaller inputs, but increases with the complexity of the inout size. I go for an example of this `1,2,3,6,8`

The generated combinations are `(2,3,6), (2,3,8)`

2,3,6 meet the condition, so that the check on 2,3,8 is not required and can be avoided. How can I change my code to use this observation?