Advertisement
whiteshark05

Untitled

Dec 2nd, 2022
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import collections
  2. a = [1, 151, 241, 1, 9, 22 , 351]
  3. a = [str(x) for x in a]
  4. count = collections.Counter()
  5. seen = set()
  6. ans = 0
  7. for num in a:
  8.     for i in range(len(num)):
  9.         new_num = num[:i] + '*' + num[i+1:]
  10.         if num not in seen and new_num in count:
  11.             ans += count[new_num]
  12.         count[new_num] += 1
  13.     seen.add(num)  
  14.  
  15. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement