Possible Duplicate:
Python: simple list merging based on intersections
I have a multiple list:
list=[[1,2,3],[3,5,6],[8,9,10],[11,12,13]]
Is there a smart and fast way to get all the sublists with at least one intersection. In my example I want that the code return
result=[[1,2,3,5,6],[8,9,10],[11,12,13]]
This works, but maybe isn’t very elegant: