in reply to Points on a line and associated intervals

i'm sleepy, but here it goes

  1. set an array of N element {distance=-1; point1; point2}
  2. for each element on your list
    1. take two adjacent elements, and calculate its distance
    2. compare the distance with the first element of the array.
      1. if the array element.distance is -1, then put your distance, and the info for your two adjacent points
      2. if you distance is lower, then, rotate the array to the right and put your elment to the first instance. Your array must be something like this [new_element, old 1, old 2,.., old n-1]
      3. if your distance is higher, try to compare with the next element of the array and start the point 2.2.

When you finish, you will have (i think) an array of 10 elemnts (at complexity O(n)), which are the ones you are searching for (supposing, of course, that your points are consecutive between them ... umm ... i'm wondering if i really grasp the problem ... i'll go to bed)

Good night

perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'