Brian Beck wrote: > [code]
Whoops, that should say:
def merge(pairs): pairs = set(tuple(sorted(p)) for p in pairs) merged = [] # Each loop will result in a new, complete sublist in the result. while pairs: p = set(pairs.pop()) remove = set([]) for pair in pairs: pairSet = set(pair) if pairSet & p: p |= pairSet remove.add(pair) pairs -= remove merged.append(list(p)) return merged
-- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list