Subj : Re: stacking algorithm To : comp.programming From : nobiscuit Date : Fri Aug 05 2005 02:54 pm Thanks to eveyone who took the time to help with this. The idea of creating a graph describing the situation got me going in the right direction. Here's the solution I went with: 1) Sort the lines by starting point, mutliples with the same starting point get sorted longest to shortest. 2) Check each line against all of the others, gathering collections of lines that fit together. No backtracking is done. Just grab the first collection that comes up. If there are no other lines that can sit on the same level with a given line, that line gets it's own level. 3) When all lines have been checked, choose the first instance of the collection with the most members and assign it to a level. 4) Remove any assigned lines from consideration and repeat the process from step 2. Continue until all lines are assigned. 5) Sort levels by total length, longest to shortest. This is not optimal but it is good enough for what we need. Thanks again! :) .