aez-notes

The Sock Drawer

A drawer contains red socks and black socks. When two socks are drawn at random, the probability that both are red is \(1/2\). (a) How small can the number of socks in the drawer be? (b) How small if the number of black socks is even?

In a drawer with \(r\) red socks and \(b\) black socks the probability of drawing two red socks without replacement is

\[ \frac{r}{r+b}\frac{r-1}{r + b - 1} \]

You can pretty easily guess that the smallest combination is \(r=3\) and \(b=1\). Getting the smallest size where \(b\) is even is a little harder. We will resort to brute force. However, we can save a lot of effort by noting that any valid solution will satisy \(r > b\), since otherwise the probability would certainly be less than \(1/2\).

First we will define the probability of two red socks in a row.

prob_red(r,b) := r * (r - 1) / ((r + b) * (r + b - 1));

Then a simple recursive function will look to find the smallest combined number of socks that leads to a probability of \(1/2\). Note that since the probability is monotonic in the number of black socks we can can exclude some lines of enquiry.

find_min_socks(r,b) :=
block( [],
  if r <= b
  then find_min_socks(r+1,0)
  else
    if is(prob_red(r,b) > 1/2)
    then find_min_socks(r,b+1)
    else
      if is(prob_red(r,b) < 1/2)
      then find_min_socks(r+1,0)
      else [r,b]
      );

print(find_min_socks(3,2));

Running this program tells us the minimum even number of black socks is \(6\) with \(15\) red socks.

Author: Alex Zarebski

Created: 2022-04-15 Fri 12:29

Validate