I have a list of strings all of length k. For every pair of k length strings which have k-1 characters in common, i want to generate a k+1 length string(the k-1 common characters + 2 not common characters). e.g i want to join 'abcd' with bcde' to get 'abcde' but i dont want to join 'abcd' with 'cdef' Currently i'm joining every 2 strings, then removing duplicate characters from every joined string and finally removing all those strings whose length != k+1.Here's the code i've written:
for i in range(0,len(prunedK) - 1,1): if k in range(1,len(prunedK),1) & i+k <= len(prunedK) -1: colocn = prunedK[i] + prunedK[i+k] prunedNew1.append(colocn) continue for string in prunedNew1: stringNew = withoutDup(string) prunedNew.append(stringNew) continue But this one is quite bad in the time aspect :(. Thanks in advance, girish -- http://mail.python.org/mailman/listinfo/python-list