A puzzle that came to me via @nathanday314 and @spottytable:

### My first thought

There are $r$ red socks and $b$ blue socks, making $n$ altogether.

The probability of drawing two red socks out is $\frac{r(r-1)}{n(n-1)} = \frac{1}{2}$

The probability of drawing two blue socks out is $\frac{b(b-1)}{n(n-1)} = \frac{1}{12}$

The probability, unstated, of drawing one of each is $\frac{2rb}{n(n-1)} = \frac{5}{12}$ – just what’s left over.

That gives us three equations to work with (although one is redundant). I’ll multiply up as I go:

• $2r(r-1) = n(n-1)$
• $12b(b-1) = n(n-1)$
• $24rb = 5n(n-1)$

Dividing the last by the second gives $\frac{r}{b-1} = \frac{5}{2}$, or $r = \frac{5}{2}(b-1)$.

That means, from the first equation, that $n(n-1) = 2r(r-1) = 2\br{\frac{5}{2}b-\frac{5}{2}}\br{\frac{5}{2}b - \frac{7}{2}}$.

That needs a tidy up: $n(n-1) = 2r(r-1) = \frac{5}{2}\br{b-1}\br{5b-7}$.

Putting this into the second equation gives $12b(b-1) = \frac{5}{2}\br{b-1}\br{5b-7}$, or $24b(b-1) = 5\br{b-1}{5b-7}$.

Because $b\ge 2$, we can divide by $b-1$ to get $24b = 5(5b-7)$.

Expanding, $24b = 25b - 35$ and $b=35$.

$r = \frac{5}{2}\times 34 = 85$, and there are 120 socks altogether.

### Double-check

Let’s go back to the equations.

• $2r(r-1) = 2\times85\times84$ and $n(n-1) = 120\times 119$.

The left-hand side is $2\times (5\times17)\times(7\times12)$, and so is the right.

• $12b(b-1) = 12 \times 35\times 34$, which is also $12\times (5\times 7)\times (2\times17)$. It works!

### A missed trick

Dividing the third by the second gives $2r = 5b - 5$.

Dividing the third by the first gives $12b = 5r - 5$.

Solve simultaneously… boom.

(Interestingly, “$b/r \approx 5/2$” from the first equation, “$b/r \approx 12/5$ from the second, and $b/r = 17/7$, the mediant of those fractions.”)