Yesterday I was pairing the socks from the clean laundry and figured out the way I was doing it is not very efficient. I was doing a naive search — picking one sock and
Consider a hash-table of size 'N'.
If we assume normal distribution, then the estimated number of 'insertions' to have atleast one sock mapped to one bucket is NlogN (ie, all buckets are full)
I had derived this as a part of another puzzle,but I would be happy to be proven wrong. Here's my blog article on the same
Let 'N' correspond to an approximate upper-bound on the number of number of unique colors/pattern of socks that you have.
Once you have a collision(a.k.a : a match) simply remove that pair of socks. Repeat the same experiment with the next batch of NlogN socks. The beauty of it is that you could be making NlogN parallel comparisons(collision-resolution) because of the way the human mind works. :-)