Comparing Sublists within Same List

Each of the lines represents an extent of a tributary length from a wood building apartment unit. So i basically have created detail components which have a gravity load value associated to it. So when truss directions switch you get cases where those extent lines overlap. Those lines at the end are creating line loads which can be transferred via ISM into analytical softwares. With that said, i am trying to eliminate any overlapping conditions by taking the lists of overlapping lines, split the longer segments into smaller segments and merge the associated loads to create 1 load instead of 3,4 or 7 on top of each other. My examples i tried to provide are only a small portion of the overall building. Here is my best example on a small scale:
These are components are the floor levels:


These are components at the roof level:

Each of the colored lines has a load associated to it which is developed from formulas within the detail component. So when there are different truss directions, or the building bumps out or in, there are different loads associated. The graph prior to examples i have sent, analyzes all the coordinates for the lines and gets a total load at the low slab level. Yet this causes overlapping loads, which is why i am looking for a method to merge the overlapping conditions and add the loads together at those locations prior to developing the actual line load. I am hoping this somewhat makes sense.

I am more so wanting in attached image for (0 list) to merge with (29 list) being all items in (0 list) exist within (29 list). Of course this is just one example so it will not be the same everytime i use the graph. I need to have all the sublists compare against themselves to find if any sublist is completed contained within another sublist. If the sublist is completed contained in another then i remove the duplicate values in the smaller count list.

Like this?

b = List.SetDifference(a,a<1>);
c = 0..(List.Count(a)-1);
d = List.AllIndicesOf((List.Count(b<1><2>)==0)<1>,true);
e = List.Flatten(List.SetDifference(d<1>,c<1>),-1);
f = List.GetItemAtIndex(a,List.SetDifference(c,e));
2 Likes

The idea and your results in your example is exactly what i would like to happen. yet when i put my list into the code block, it is giving me the exact same original list. It is still not merging my 0 list into my 29 list.

edit: If i convert the original list into string then your method works. I will continue with thought process and will see if it plays nicely.

After testing a couple different scenarios, i found that this method works provided there is only one time in which the there are duplicates. If there are multiple smaller sublists with the same values as those with larger sublists the method fails. Is there a possibility to accommodate that situation?

Kindly prepare a simple sample using strings (as in the examples I’ve provided) to demonstrate the cases that don’t work. Would help others understand the issue better.