4 ms·
The real world meets the world of algorithms. I solve the issue by buying only 1 color and type of sock.
by coldcode 13y ago
The real world meets the world of algorithms. I solve the issue by buying only 1 color and type of sock.
- notduncansmith 13y agoIt's worked for me for just shy of a decade.
- yen223 13y agoExactly. O(1) FTW!
- rtpg 13y agowell 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)
- theseoafs 13y agoThis would be O(n), since the time it takes to pair your socks is still proportional to the number of socks you have
- yen223 13y agoThe 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).
- bovermyer 13y agoWhat happens when your brand/model is discontinued?
- privong 13y agoI 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 :)
- coldcode 13y agorealloc() - delete all and buy new ones.
- _puk 13y agoFragile - 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.