• Emily Zhang
  • Fiddler

Can You Find a Matching Pair of Socks (Again)?

2024 Jun 282024 June 28 Problem Back

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 19\frac{1}{9}91​ 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 28\frac{2}{8}82​ chance. However, for the chance that it's the first pair, it would be (1−19)28=29(1-\frac{1}{9})\frac{2}{8}=\frac{2}{9}(1−91​)82​=92​.

Next up, 3 possible pairs with 7 socks left makes a 37\frac{3}{7}73​ chance, for a (1−19−29)37=27(1-\frac{1}{9}-\frac{2}{9})\frac{3}{7}=\frac{2}{7}(1−91​−92​)73​=72​ chance of being the first. Then 4 possible pairs with 6 socks left makes a 46\frac{4}{6}64​ chance, for a (1−19−29−27)46=1663(1-\frac{1}{9}-\frac{2}{9}-\frac{2}{7})\frac{4}{6}=\frac{16}{63}(1−91​−92​−72​)64​=6316​.

With 5 possible pairs and 5 socks left, the sixth sock drawn guarantees a pair will be formed, meaning the remaining 1−19−29−27−1663=8631-\frac{1}{9}-\frac{2}{9}-\frac{2}{7}-\frac{16}{63}=\frac{8}{63}1−91​−92​−72​−6316​=638​ 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 2\sqrt22​ (rounded to the nearest integer for the given precision)! This would mean that the trend this follows, for NNN pairs of socks, would be round(2N)\textrm{round}(\sqrt{2N})round(2N​).

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: round(2N)+1\textrm{round}(\sqrt{2N})+1round(2N​)+1.

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

Back to Fiddler list
© 2024 Emily Bradon Zhang·Support Gaza Recovery