ruby one-liner
\ndef count_pairs(nums, k)\n    nums.each_with_index.to_a.combination(2).count { |(x,i), (y, j)| x==y && i*j % k == 0 }\nend\n
```\ndef count_pairs(nums, k)\n    nums.each_with_index.to_a.combination(2).count { |(x,i), (y, j)| x==y && i*j % k == 0 }\nend\n```
[]