Another way to look at the problem is that the child pulls pairs of socks until there are none or just one left, then looks for a matching pair. Calculate the solution using Probability 101 after computing Pr(no pair is a white match) and Pr(no pair is a patterned match | no pair is a white match).

Pr(no pair is a white match): If and only if m+2 >=2n, a white match is assured. If m+2 <2n, no pair is a white match unless and until either m is odd and there are exactly mpairs with exactly one white sock and the leftover sock is white, or m is even and there are exactly m-1 pairs with exactly one white sock and the leftover sock is white.

Consider the patterned socks to be indistinguishable for this calculation. The socks can be drawn in (m + 2n) different ways. When m is even, count the number of ways to draw the socks without a white pair as (m/2 + n) pick m ways to choose pairings with a white sock times 2m ways to draw those pairs. When m is odd, we obtain (((m1)/2 + n) select (m-1)) *2m-1 ways to have a white leftover sock and ((m1)/2 pick m) 2m ways to have a patterned leftover sock.

Pr(no pair is a patterned match | no pair is a white match): I'll take care of the situation where m is even, and you or someone else can take care of the other case. We have a total of m/2 + n pairs, with m containing exactly one white sock and n -m/2 pairs containing two patterned socks. The alternating sum is obtained by using inclusion-exclusion on subsets of matching patterns.

i 1 1 1
∑ (−1) (m choose i) (---------- × ---------- × … × ---------------)
i≥0 2n + m − 1 2n + m - 3 2n + m - 2i + 1

If the number of ways to choose the I patterns is m choose I and the probability that all I are matched is the product (for each pattern in some order, we reveal the first sock and then compute the probability that its mate matches).

The odd case works similarly to the other examples, except that we divide them into groups based on whether the residual sock is white or not.