Advertisement
Guest User

Untitled

a guest
May 21st, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. n = 7
  2.  
  3. arr = [ 1,2,1,2,1,3,2 ]
  4.  
  5. def matchingPairs(qty,socks):
  6. pairs = 0
  7. counts = {}
  8. for s in socks:
  9. if s in counts:
  10. counts[s] += 1
  11. else:
  12. counts[s] = 1
  13.  
  14. print(counts)
  15.  
  16. total = 0
  17. for val in counts.values():
  18. total = total + int(val/2)
  19. return total
  20.  
  21.  
  22. print (matchingPairs(n,arr))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement