Can You Find a Matching Pair of Socks (Again)?
This Week's Fiddler
For the first sock drawn, there is no chance to make a pair. For the second, there is 1 possible pair to be made with 9 socks left, so there is a chance of making a pair. If the second draw doesn't yield a pair, then there are 2 possible pairs with 8 socks left, making a chance. However, for the chance that it's the first pair, it would be .
Next up, 3 possible pairs with 7 socks left makes a chance, for a chance of being the first. Then 4 possible pairs with 6 socks left makes a chance, for a .
With 5 possible pairs and 5 socks left, the sixth sock drawn guarantees a pair will be formed, meaning the remaining is the chance of needing six socks to draw one pair for the first time.
The highest chance of these is at the fourth sock, when there are 3 possible pairs to be made.
Answer: 4
Extra Credit
Creating a Python program to see how many pairs have already been drawn by the time the most likely time a pair is about to form:
for pow in range(8):
n = 100**pow
accum = 0
best, best_k = 0, 0
for k in range(1, n + 1):
p = (1 - accum) * k / (2 * n - k)
accum += p
if p > best:
best = p
best_k = k
else:
break
print(n, best_k)
1 1
100 14
10000 141
1000000 1414
100000000 14142
10000000000 141421
1000000000000 1414214
100000000000000 14142136
Notice that these are just the digits of (rounded to the nearest integer for the given precision)! This would mean that the trend this follows, for pairs of socks, would be .
The question we're answering is just a bit different, as it's how many socks should be drawn to achieve a pair. This is just 1 sock more than the number described here: .
Although I wasn't sure how to concretely prove this, it's pretty fascinating that this emerges as such a clean trend!
Answer: round(sqrt(2N)) + 1