數字排序,波動增加,相似於股票走勢圖,整體趨勢是增加型的
數組
import randomapp
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))
=======================================================dom
import random
spa
c = range(18) 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)