Ubuntu下格式化U盘
Ubuntu12.04下使用mysql, 默认版本5.5.34

python ascending permutation 产生升序的排列

kitt posted @ 2013年11月06日 16:32 in 技术类 Tech , 1484 阅读
import itertools
x = [10, 20, 30, 40, 50]
len = 3
for i in itertools.permutations(x, len):
    if i == tuple(sorted(i)): print i
Avatar_small
依云 说:
2013年11月06日 20:49

其实这里用 filter 挺好的。

Avatar_small
kitt 说:
2013年11月10日 15:56

print filter( lambda i:i==tuple(sorted(i)), itertools.permutations(x, len) ) 这样吧?@依云:


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter