Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import collections
- a = [1, 151, 241, 1, 9, 22 , 351]
- a = [str(x) for x in a]
- count = collections.Counter()
- seen = set()
- ans = 0
- for num in a:
- for i in range(len(num)):
- new_num = num[:i] + '*' + num[i+1:]
- if num not in seen and new_num in count:
- ans += count[new_num]
- count[new_num] += 1
- seen.add(num)
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement