Boys and girls ending up in same pair

55 Views Asked by At

100 boys and 100 girls are randomly assigned into 100 pairs. What are some ways to calculate how many groups get 2 girls?

I can calculate this using a computer program in Python, that I know, how do I think about it mathematically, that I want to learn.

# cook your code here
import random
list=[]
girls=[]
boys=[]
duplicate = 0

for i in range(200):

          r=random.randint(1,100)
          if list.count(r) < 2: 
              list.append(r)
              if i % 2 == 0:
                  girls.append(r)
                  if girls.count(r) == 2: 
                      duplicate += 1
              else:
                  boys.append(r)

          else:
              i -= 1


print(duplicate)