How to pair socks from a pile efficiently?
stackoverflow.com
stackoverflow.com
With different patterns it's easier as the wear is constant for each pair. OCD mileage may vary :)
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?
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?
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.
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).
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.
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.
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.
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.
https://hn.algolia.com/?q=how+to+pair+socks#!/story/forever/...
The most recent repost was over a year ago, but not by much.