Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

wxjmfauth at gmail.com wxjmfauth at gmail.com
Sun Feb 22 03:15:51 EST 2015


>>> z = [set(s) for s in ("ABEF", "GHLPQ", "CDEF", "EXZ", "LMR", "OMY")]
>>> x = set()
>>> for e in z:
...     x = x.union(e)
...     
>>> x
{'A', 'C', 'B', 'E', 'D', 'G', 'F', 'H', 'M', 'L', 'O', 'Q', 'P', 'R', 'Y', 'X', 'Z'}
>>> ''.join(x)
'ACBEDGFHMLOQPRYXZ'
>>>




More information about the Python-list mailing list