Generating multiple lists from one list

Girish Sahani girish at cse.iitb.ac.in
Thu Jul 6 00:23:11 EDT 2006


hello ppl,

  Consider a list like ['a.1','b.3','b.4','c.2']. Here 'a','b','c' are
objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1
and b.1 cannot exist together. From this list i want to generate
multiple lists such that each list must have one and only one instance of
every object.
 Thus, for the above list, my output should be:
  [['a.1','b.3','c.2'],['a.1','b.4','c.2']]
 Another example: Let l = ['a.1','b.3','b.4','c.2','c.6','d.3']. Then
output should be [['a.1','b.3','c.2','d.3'],['a.1','b.3','c.6','d.3'],
['a.1','b.4','c.2','d.3'],[['a.1','b.4','c.6','d.3']

 Can anyone suggest me a time-efficient method for doing this??

TIA,
girish





More information about the Python-list mailing list