Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = 7
- arr = [ 1,2,1,2,1,3,2 ]
- def matchingPairs(qty,socks):
- pairs = 0
- counts = {}
- for s in socks:
- if s in counts:
- counts[s] += 1
- else:
- counts[s] = 1
- print(counts)
- total = 0
- for val in counts.values():
- total = total + int(val/2)
- return total
- print (matchingPairs(n,arr))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement