Hacker News new | past | comments | ask | show | jobs | submit login
[dupe] How to pair socks from a pile efficiently? (stackoverflow.com)
45 points by arono on April 29, 2014 | hide | past | favorite | 41 comments



I have 18 pairs of the same sock. I found that the most efficient way. YMMV.


Isn't this making it especially more complex because now you have to match based on wear, not just the pattern?

With different patterns it's easier as the wear is constant for each pair. OCD mileage may vary :)


I do the same thing and I buy socks in large batches replacing old batches. This is by far the best life hack I have implemented. My socks are comfortable, versatile and I never need to worry about pairing. I did this after literally seeing how my upright washing machine swallowed a sock between the drum and the drum container. I never took it apart to see how many lone socks are left there.


I do pretty much the same thing (although I have two colours :) Since you don't ever pair any of your socks the wear is fairly even since you are picking two random socks every morning. If a single sock gets a hole in it you just throw it out!


If you really had OCD, you would always do laundry, pull the contents of your sock drawer forward, put clean socks at the back, and only take socks from the front. Problem solved.


If you really had OCD, you would do laundry, wash your hands to avoid spreading diseases to your family, pull the contents of your sock drawer forward, wash your hands to avoid spreading diseases to your family, put clean socks at the back, wash your hands to avoid spreading diseases to your family, and only take socks from the front, after you have washed your hands to avoid spreading diseases to your family. Problem solved, if the problem has been washed, of course.


I have two sock drawers. One for drawing from and one for depositing to. When the draw pile is empty, switch.


I upvoted because you make an interesting point, but I'm surprised to hear anybody matches socks that carefully!

Also, wouldn't the wear work out to be roughly equal if you alternate socks roughly equally?


> Also, wouldn't the wear work out to be roughly equal if you alternate socks roughly equally?

My guess is that this is a poisson process, so there would be a tail of (a few) socks which are randomly worn more than others?


Socks that haven't been worn between the last time you've done laundry and the most recent time end up at the bottom of the drawer. So the worn socks get picked again and reworn before the ones at the bottom of the drawer. Then one week you skip laundry, everything ends up in the wash the next week and you realize that you have very different wear levels on your socks.


No because you bought them all at the same time and washed them all at once. And you did the same activity each day resulting in the same wear for each sock. If you're that OCD, you would.


Interesting, hadn't thought about it that way. Definitely bugs me when I wear two socks of the same color/brand/etc. that fit differently due to age.


Probably more efficient is to not give a shit about the possibility of wearing odd socks. Which I don't.


Meta warning...

That breaks down in the world of finance:)

For some reason, it was decided that people would be judged based on the socks that they wear.

I guess when you have to wear a suite each day you need to differentiate yourself and after a watch socks are the next best way?


But is it pairs of the right foot's sock, or the left foot's sock?


An obvious solution is buying 2 batches of different colors, always wearing random green on left leg and random orange on right. Problem solved ;-)


The real world meets the world of algorithms. I solve the issue by buying only 1 color and type of sock.


What happens when your brand/model is discontinued?


I had this happen a few years ago, though in a slightly different fashion. The same "model" of sock was around, but the design changed once (width of stripes) and the material/construction quality changed several times. So despite having had ~15 pairs of the "same" socks, I still had to match because otherwise they would feel different on my feet. That's obviously not an issue in the grand scheme of things, but it bothered me :)


realloc() - delete all and buy new ones.


Fragile - potential to fall apart at Christmas!

My cunning plan is to fold the top of one sock over the other, so they come out ready paired.

Spawning a child is a great answer though.


It's worked for me for just shy of a decade.


Exactly. O(1) FTW!


well considering that the number of socks is limited by the number of atoms in the universe, we can make pretty much any time-bound algorithm O(1)


This would be O(n), since the time it takes to pair your socks is still proportional to the number of socks you have


The idea is that I don't need to pair my socks. I can just take any random 2 socks from the heap whenever I'm going out, since they are all the same. Hence, O(1).


The first answer is kind of labourous, isn't?

I thought about simply removing a sock from the pile and isolating it. One for one, maybe puting the man's socks on the left and the women's on the right.

So everytime you grab a new sock you can quickly check if you already isolated the pair of that one.

This way you just have to grab each sock once. (this is similar to the second answer, but no need to prepare a flat pile to begin with).


Yup. Unless you have millions of socks, you can afford to "hash" each style sock by color + pattern + size + whatever, rather than repeatedly into ever-smaller piles based on just one of the metrics.

That's actually how I pair my socks from the laundry pile, anything else seems kind of silly...

This kind of recursive hash partitioning is actually being done by SQL Server when it needs to hash join or hash aggregate over huge data sets.

My pile of socks is not a huge dataset. They easily fit on the seat of my couch when laid out in pairs.


No one owns enough socks of enough different kinds to make the accepted solution the most efficient.

It's much easier to simply try for a match on an unmatched sock, and if there is no match put that sock into cache (usually somewhere else on the bed). Your cache will probably never get above about 8 socks without a match.


"No one owns enough socks of enough different kinds"

Not sure if you're making a legitimate YAGNI argument, or falling into a programmer fallacy of believing you can safely generalize from your own experience to your users...

I'm leaning towards the latter, and am further going to suggest that your experience might be limited to being single, and likely male, and that it generalizes badly on any axis away from that state.

This problem feels like a surprisingly good example of how your personal intuitions about a problem space can lead you to make incorrect simplifying assumptions to find an elegant solution, that will completely fail when they run into the real needs of your actual users.


How many different kinds of sock do you own? I fold socks for four people - my wife and my two children, contrary to your ignorant assertion - and between the four of us we may have a dozen different kinds of sock.


The answer is http://www.bargain-bulk-sock-sales.com/ Get a gross of either ankle, high or dress socks. ALL EXACTLY THE SAME. When a sock goes bad, take it out of circulation and grab a new one from the box. I bought a gross in 2004 and I'm about 1/2 of the way through. So at that point it was about $90 for 10 years of socks with no time spent on matching socks. They all match.


Give the pile to a toddler. A lot can be learnt from sorting and hanging the daily washing with a young child, on both sides.


My grandfather used to give me coins to count. Loved it. (Was older than a toddler, though..)


I wouldn't pair socks, personally. I would just create piles and offload pairing to each sock-wearing instance. This becomes efficient by creating piles based on intended use, and allowing each pile to have easily-distinguished differences such as color difference or size. What's interesting is that your pile criteria changes based on your socks. For me I have a long-warm pile, long-cool pile, and short pile. But if I didn't have long or short socks i'd have to create new piles: dress, casual, athletic, for example. Another pile set might be long-short-dress, long-short-casual, long-short-athletic, or long-short-warm, long-short-cool, long-short-athletic, etc.

In each case, the pile has socks that are so distinct that it becomes trivial to identify a matching pair in the pile. This is also why I don't sort by color.


This has been posted many times to HN:

https://hn.algolia.com/?q=how+to+pair+socks#!/story/forever/...

The most recent repost was over a year ago, but not by much.


I fold each pair of socks into each other when I put them into the washing machine and then unfold them when hanging up to dry. All pairs stay together, no sorting necessary.


Or stop caring (that's what I do).


i made the 'mistake' of buying socks where some have a blue logo, some have a green logo, and some have a grey logo. I forced myself to be 100% color blind and mis-match the colors but consider that in my mind as a true match.


Or, you know, do laundry more often so the socks dont actually pile up. May I interest you in a to-do app?


This is still Hacker News, right?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: