aboutsummaryrefslogtreecommitdiff
path: root/challenge-262/eric-cheung/python/ch-2.py
blob: b5c88d67c468124595e60bcaf89c1127281d3530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from itertools import combinations

## Example 1
## arrInt = [3, 1, 2, 2, 2, 1, 3]
## nK = 2

## Example 2
arrInt = [1, 2, 3]
nK = 1

arrCombList = combinations(range(len(arrInt)), 2)

arrOutput = [arrIndxLoop for arrIndxLoop in list(arrCombList) if arrInt[arrIndxLoop[0]] == arrInt[arrIndxLoop[1]] and arrIndxLoop[0] * arrIndxLoop[1] % nK == 0]

print (len(arrOutput))