Python Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nTry to generate possible swaps a digit can lead to add up how many pairs are posible wi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTry to generate possible swaps a digit can lead to add up how many pairs are posible with the combination if the generated digit is available\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(N * D ^ 4)$$\n\n\n# Code\n```python3 []\nclass Solution:\n    def countPairs(self, nums: List[int]) -> int:\n        \n        n = len(nums)\n        available_set= []\n\n        visited = defaultdict(lambda:0)\n\n        for ele in nums:\n            ele = str(ele)\n            if len(ele) < 7:\n                ele = \'0\' * (7 - len(ele)) + ele\n            available_set.append(ele)\n            \n        count = 0\n        for ele in available_set:\n            generated_set = set()\n            count += visited[ele]\n            generated_set.add(ele)\n            ele = list(ele)\n            for i in range(7):\n                for ii in range(i+1,7):\n                    ele[i],ele[ii] = ele[ii],ele[i]\n                    digit = "".join(ele)\n                    if digit not in generated_set:\n                        generated_set.add(digit)\n                        count += visited[digit]\n                    for iii in range(7):\n                        for iv in range(iii+1,7):\n                            ele[iii],ele[iv] = ele[iv],ele[iii]\n                            digit = "".join(ele)\n                            if digit not in generated_set:\n                                count += visited[digit]\n                                generated_set.add(digit)\n                            ele[iii],ele[iv] = ele[iv],ele[iii]\n                    ele[i],ele[ii] = ele[ii],ele[i]\n            digit = "".join(ele)\n            visited[digit] += 1\n        \n        return count\n                \n\n\n```
['Python3']