# Missing sock puzzle

There is a riddle on YouTube: Can You Solve The Missing Sock Puzzle?

The riddle goes like this:

A statistician keeps a simple wardrobe. He only purchases pairs of black socks and white socks, and he keeps all of the socks in a pile in the drawer. Recently one of the socks was lost in the laundry.

The socks have a mathematical property. If you select two socks at random from the drawer, the socks will match in color exactly $$50\%$$ of the time.

The statistician owns more than $$200$$ socks but less than $$250$$ socks, and there are more black socks than white socks.

How many socks of each color are there?
And, which color sock was lost in the laundry?

The solution in the video uses the "$$50\%$$ matching mathematical property" as a "fact" to conclude that the total number of socks must be a "perfect square", and since the only perfect square between $$200$$ and $$250$$ is $$15^2$$, the total number of socks is therefore $$225$$. And then further concludes that there must be $$120$$ black socks ($$60$$ pairs) and $$105$$ white socks ($$52$$ pairs plus $$1$$ unmatched white sock).

Now, this just seems wrong to me. I understand that probability is not (always) intuitive, but, I feel (intuitively) that there is something wrong (invalid) with the initial setup of the question.

Specifically, I have a problem justifying the "mathematical property" of the socks where "if you select two socks at random from the drawer, the socks will match in color exactly $$50%$$ of the time".

I know from the stated conditions, that there are more black socks than white socks, so surely, the probability can't be $$50\%$$. And merely stating it is $$50\%$$ doesn't make it so.

An explanation given in the comments for the video is that:

Probability of picking a black pair: $$\frac{120}{225} \cdot \frac{119}{224} = 28.33\%$$

Probability of picking a white pair: $$\frac{105}{225} \cdot \frac{104}{224} = 21.67\%$$

$$28.33\% + 21.67\% = 50\%$$

This argument seems compelling, but I think it's flawed.

I keep looking at it with these two examples:

If you start with $$220$$ black socks ($$110$$ pairs), and $$5$$ white socks ($$2$$ pairs plus $$1$$ unmatched sock), the chance of picking a pair is probably $$95\%$$ or better. And, if you start with $$224$$ black socks ($$112$$ pairs), and $$1$$ (unmatched) white sock, the chance of picking a pair is better than $$99\%$$.

Then:

1. Start with $$104$$ black socks ($$52$$ pairs) and $$104$$ white socks ($$52$$ pairs).
2. The probability of picking a pair of socks is $$50\%$$.
3. You add an additional pair of black socks, and the probability of picking a pair of socks increases (to slightly more than $$50\%$$).
4. As you add additional pairs of black socks, the probability of picking a pair increases more and more.
5. Then, according to this "riddle", when you reach $$120$$ black socks ($$60$$ pairs), and you add an additional (single) white sock, the probability of picking a pair of socks suddenly drops back down to $$50\%$$.

What's actually happening here?

Let there be $b$ black and $w$ white socks. Since the probability to draw two matching socks is ${1\over2}$ we have $${{b\choose 2}+{w\choose2}\over{b+w\choose 2}}={1\over2}\ ,$$ which reduces to $$(b-w)^2=b+w\ .$$ We are told that $200< b+w< 250$, and as $b+w$ has to be a square we now know that $b+w=225$, hence $b-w=15$. This then implies $b=120$, $w=105$, whatever might have been the cause of the "odd sock". The latter has to be white, as $w$ is odd.

• So elegant, as always. But how can we deduce the color of the lost sock, as it is part of the question? Dec 13 '16 at 17:55
• I suppose we can use @Hagen Von Eitzen's argument: as $w$ is odd, the missing sock is white! Dec 13 '16 at 17:58
• @Kuifje: Thank you for the comment. I have edited my answer suitably. Dec 13 '16 at 18:26
• Also, shouldn't the riddle mention that the mathematical property of the socks always holds, no matter the number of socks? Because we are using it when one the socks is lost, assuming the property holds even when the drawer is incomplete. Dec 13 '16 at 18:37

If there are $b$ black and $w$ whicte socks, then the probability of getting a black pair is $$\frac b{b+w}\cdot \frac{b-1}{b+w-1}$$ and the probability of getting a white pair is $$\frac w{b+w}\cdot \frac{w-1}{b+w-1} .$$ These should sum up to $50\,\%$, so $$\frac{b(b-1)+w(w-1)}{(b+w)(b+w-1)}=\frac12.$$ If we introduce the total number of socks, $s=b+w$, and eliminate $w$, this becomes $$\frac{b(b-1)+(s-b)(s-b-1)}{s(s-1)}=\frac12,$$ which can be transformed to $$\tag1 4b^2-4sb+s^2-s=0.$$ Viewing this as a quadratic in $b$, $$b=\frac{4s\pm\sqrt{16s^2-16(s^2-s)}}{8}=\frac{s\pm\sqrt{s}}{2}.$$ We conclude that $s$ is a perfect square $s=m^2$ for some natural $m$. Note that by symmetry, also $w=\frac{s\pm\sqrt s}{2}$, so that $b>w$ implies $$b=\frac{m^2+m}2,\quad w=\frac{m^2-m}2.$$ From $200 < s=m^2<250$, we infer $m=15$, so $$s=15^2=225,\quad b=\frac{225+15}2=120,\quad w=\frac{225-15}2=105$$ and as $w$ is odd, the missing sock is white.

• Do we have to mention that we assume that the property (if you select two socks at random from the drawer, the socks will match in color exactly 50% of the time) holds no matter the number of socks in the drawer? Because we are using it to find the number of socks after one has been lost. Dec 13 '16 at 18:04

Your math is flawed - you forget to account for the sock already picked.

Start with 104 black socks (52 pairs) and 104 white socks (52 pairs). The probability of picking a pair of socks is 50%.

The probability of picking a matching pair of socks is not $50\%$. It's $\frac{103}{207}$ where $103$ is the number of socks matching your first pick and $207$ is the total amount of socks remaining after you have picked the first sock. That is approximately $49.8\%$.

In general, for any amount of black and white socks the probability of picking a matching pair is $P(\text{black pair}) + P(\text{white pair})$ (the two events are disjoint). With $120$ black and $105$ white socks we get the following values:

$P(\text{black pair}) = \frac{120}{225} \times \frac{119}{224} = 28.33...\%$

$P(\text{white pair}) = \frac{105}{225} \times \frac{104}{224} = 21.66...\%$

Adding up to $50\%$.

Let’s write $b$ for the number of black socks and $w$ for the number of white socks.

How many ways are there to get a pair of matching socks?

In order to select two black socks, there are $b$ socks for the first draw, and then $b – 1$ socks available for the second draw (there is one less because a black sock was already drawn).

Matching pair of black socks: $b(b – 1)$

Similarly, the number of ways to get a pair of white socks is:

Matching pair of white socks: $w(w – 1)$

If the two socks do not match, then you either drew a white sock followed by a black sock, or vice versa.

Unmatched pair of socks: $wb,bw$

The number of ways to get a pair of matching socks is the sum of the ways to get a pair of black socks and white socks.

Matching pair of socks: $b(b – 1) + w(w – 1)$

The number of ways to end up with a mismatched pair is the sum of the two possible ways to get an unmatched pair:

Mismatched pair of socks: $wb + bw = 2bw$

If you draw a pair of socks, half the time you get a matching pair and half the time you get a mismatched pair. So the number of ways to get a matching pair equals the number of ways to get a mismatched pair.

$b(b – 1) + w(w – 1) = 2bw$

Now we can simplify the above expression:

$$b(b – 1) + w(w – 1) = 2bw$$

$$\Rightarrow b^2 – b + w^2 – w = 2bw$$

$$\Rightarrow b^2 – 2bw + w^2 = b + w$$

$$\Rightarrow (b – w)^2 = b + w$$

The total number of socks is $b + w$. This has to be equal to a number between $200$ and $250$. Furthermore, we have deduced this number has to be a perfect square, since $(b – w)^2$ is a perfect square.

The only perfect square between $200$ and $250$ is $15^2 = 225$.

Therefore: $b + w = 225$ and $(b – w)^2 = 15^2$ giving us,

$b + w = 225$ and $b – w = 15$

We can add the two equations to get: $2b = 240 \Rightarrow b = 120$

We then solve to find $w = 105$.

As the socks were originally purchased in pairs, the missing sock corresponds to the color with an odd number of socks. The color of the missing sock is therefore white.