How do you pair your socks? CS at its finest. 1) For each color - TopicsExpress



          

How do you pair your socks? CS at its finest. 1) For each color of socks, form a pile. Iterate over all socks in your input basket and distribute them onto the color piles. 2) Iterate over each pile and distribute it by some other metric (e.g. pattern) into a second set of piles 3) Recursively apply this scheme until you have distributed all socks onto very small piles that you can visually process immediately "The best real-world partitioning I can think of is creating a rectangle of piles: one dimension is color, the other is pattern. Why a rectangle? Because we need O(1) random-access to piles. (A 3D cuboid would also work, but that is not very practical.)" Best case: every sock is identical (You buy your socks from Costco). stackoverflow/questions/14415881/how-to-pair-socks-from-a-pile-efficiently Sean Watson
Posted on: Fri, 19 Jul 2013 15:51:57 +0000

Trending Topics



Recently Viewed Topics




© 2015