# 50:50 Sock Puzzle

A couple of years ago, I wrote about the classic puzzle of how many socks you need to take out a drawer, in the dark, to ensure you get a matching pair. It’s a pretty common-sense problem, and well known. You can read the full solution (and an extension about the probability of pulling them out in matching pairs) here.
Let’s say, however, that you are a gambling person. Rather than guaranteeing you get a matching pair, let’s say you’d be happy with a 50:50 chance of getting a pair (and you are picky about the colour).
Specifically:
There is a drawer containing R red socks, and W white socks. What is the minimum number of socks there needs to be in the draw to be able to pull a pair of red socks out with 50% probability? What would be the breakdown of socks in the drawer?
Let’s look at the math: The first sock that you pull out will have R/(R+W) chance of being red; there are R red socks out of a total of (R+W). The second sock you pull out, will have (R-1)/(R+W-1) chance of being red; there is one less red sock, and also one less total socks to choose from. Multiplying these together, and equating this to 1/2, we have our equation:
Plugging in a few trivial numbers, we can see a solution if R=3 and W=1 (The first pull has a 3/4 chance of getting a red sock, and the second pull has a 2/3 chance of getting a red sock).

## Pairs

I don’t know about you, but I buy my socks in pairs (yes, occasionally the washing machine will mysteriously ‘eat’ one, but we will ignore that. If lose to sock in the laundry, the singleton does not return to the drawer. The lonely sock stays in the laundry room for its twin to mysteriously reappear). For this reason, there would never be an odd number of either of the socks in the drawer.
(For the record, I don’t actually own any white, or red, socks. My socks are a combination of black, grey, beige, and brown; whatever Costco happens to be selling when I need more).
What would be the minimum number of socks so that there would be a 50:50 chance of getting a red sock if there were an even number of each kind of sock in the drawer? We can’t simply double the above answer; the ratios would not work. Let’s get a formal answer.
Multiplying out the above equation, and using the standard quadratic formula:
We are looking for Diophantine (integer) solutions to this equation.
A few lines of script give the first few solutions. Although six white socks and fifteen red socks gives us a 50:50 solution, there are an odd number of red socks. The next solution at {35,85} is also odd, as are the next few …
We have to go all the way to 59,992 white socks and 144,834 red socks before we get our first answer with an even number of each pair of socks.
That’s an awful lot of socks!
UPDATE: I'm embrassed to say that I made a mistake when putting out this article. I did the calculations using fixed preccion numbers, and because of their size, I had rounding errors. Some of the solutions I printed in the earlier version of this article were very, very close, but not exactly 1/2. Thanks to everyone who brought this to my attention, in particular, Jeffrey Pauletto, who was the first to mention it. I've corrected the table below for the first ten integer solutions. There's no solution for an even number of socks in there!

## Table

White Socks Red Socks
13
615
3585
204493
1,1892,871
6,93016,731
40,39197,513
235,416568,345
1,372,1053,312,555
7,997,21419,306,983