I don't know about a large calculation time, but this seems to work: >>> def rightshift(a): ia = a[:] for i in range(len(ia)-1,0,-1): if ia[i-1] == 1 and ia[i]!=1: ia[i]=1 ia[i-1]=0 return ia
>>> l = [1,0,0,0,0,1,1,1,0,1,1,0,1,0] >>> while l != rightshift(l): l = rightshift(l) print l [0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1] [0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1] [0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1] [0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1] [0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1] [0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1] [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1] -- Email: singingxduck AT gmail DOT com AIM: singingxduck Programming Python for the fun of it. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor