Minimum Equal Pairs in Set Containing Specific Values

16 Views Asked by At

I'm currently working on a program which involves presenting equal pairs of values to a user, from a list pseudo-randomly populated with values between 1 and 8.

E.g. [1,5,5,4,3,4,5,5] would return 3 pairs of equal values:
(5,5)
(4,4)
(5,5)

How would I calculate the minimum number of equal pairs in a list of length n?