数字排序,波动增长,类似于股票走势图,总体趋势是增长型的
import random
def scrambled(l, w=2):
c = l[:]
return [c.pop(min(random.randint(0, w), len(c)-1)) for x in l]
print scrambled(range(18))
=======================================================
import random
l=[ ]
for x in range(18):
a=c.pop(min(random.randint(0, 2), len(c)-1)) #len(c)-1防止出现数组越界;
print a
l.append(a)