hi everyone my target is implement a function controlla(string - a binary string-) that check if there is in a string two equal not overlapping subsequences at least of length limitem:
my code: def controlla(test): # print test limitem=4 lunghezz=len(test) l1=lunghezz-limitem+1 l2=lunghezz-limitem+1 f=0 for ii in range(l1): for kk in range(l2): t1=test[ii:ii+limitem] t2=test[kk:kk+limitem] if abs(ii-kk)>=limitem : if t1==t2 : f=1 if f==1 : break break break if f==0 : return test else: return 'no' the question is: Is there a faster way doing that? I don't know, changing string into list or array, using map, or module, using different loop, regular expression,funcional programming , list comprehensions , sets, different looping techniques, i dont know.......(!) -- http://mail.python.org/mailman/listinfo/python-list