+

Cookies on the Business Insider India website

Business Insider India has updated its Privacy and Cookie policy. We use cookies to ensure that we give you the better experience on our website. If you continue without changing your settings, we\'ll assume that you are happy to receive all cookies on the Business Insider India website. However, you can change your cookie setting at any time by clicking on our Cookie Policy at any time. You can also see our Privacy Policy.

Close
HomeQuizzoneWhatsappShare Flash Reads
 

These Software Engineers Wrote An Algorithm For Efficiently Pairing Socks In A Pile Of Laundry

Apr 29, 2014, 21:47 IST

Twitter@TacoBell

Leave it to computer scientists to determine the most efficient way to pair up clean socks in a pile of laundry. When one developer was going through his laundry, he realized how much time he was wasting taking one sock and looking for its pair. His solution was to post a question on Stack Overflow, a Quora-like question and answer site for professional and enthusiast programmers.

Advertisement

This urgent plea received 33 answers that look into the depths of the sock-pairing quandary. One answer suggests using recursive hash partitioning, which is actually used by the Microsoft database management system SQL Server. In the case of the mismatched socks, you would make a pile for each color of socks. Then you would divvy that up by pattern or another metric, and recursively apply until you're left with two socks in each pile. The same engineer suggests another solution: parallelism (or getting your friends to help you out).

One eager Stack Overflow user commented on this answer: "This is exactly what I do! I make piles dependent on the style of the opening of the sock." And this enthusiasm is carried throughout the lengthy discussion.

Another gem of an answer actually puts his process of sock-pairing into code:

Others suggest non-algorithmic solutions like throwing out all of your socks and purchasing identical socks to avoid the problem entirely. For more valuable insights on how to best pair your socks, check out the full question and answer.

Advertisement

And ladies and gentlemen, there you have it. A computer scientist's guide to taking one sock and finding its companion.

You are subscribed to notifications!
Looks like you've blocked notifications!
Next Article