in reply to Re: Comparing 2D coordinates in thread Comparing 2D coordinates
Close but no coconut
Not that I am criticising  the problem is mine for not explaing the specifications clearly enough.
A final stab at defining it:
Given a set of 1D coordinates how can I calculate the maximum coverage using discrete nonoverlapping sets.
e.g.
for the set (1,3),(4,6),(25) the mximum coverage I can find is (1,3) + (4,6).
Is that good enough or should I just stop digging?
:)
Re3: Comparing 2D coordinates by dragonchild (Archbishop) on Jul 31, 2003 at 16:22 UTC 
Given that definition, belg4mit is absolutely right  this is a 1D knapsack. Look in any upperlevel algorithms book or just google "knapsack algorithm". My algorithm would have given you the smallest number of largest individual segements without taking into account the total coverage. (It can be easily extended to that by figuring out the all the overlaps for a given new segment, then comparing the total coverage between the new segment and the old segment(s). However, I would go with the algorithm that PhD's have optimized. If you cannot figure out how to write it, I'd be glad to provide an implementation of my naive version.)
 We are the carpenters and bricklayers of the Information Age. The idea is a little like C++ templates, except not quite so brainmeltingly complicated.  TheDamian, Exegesis 6 Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.  [reply] 
