Re: [問題] 1-9位數不重複印出來 (Python)

作者: suhorng ( )   2016-12-03 11:08:32
既然 Python 那當然是要作弊啊
#!/usr/bin/env python3
import itertools
import sys
print(', '.join("".join(xs) for i in range(1,int(sys.argv[1])+1) \
for xs in itertools.permutations("0123456789", i) \
if xs[0]!='0'))

Links booklink

Contact Us: admin [ a t ] ucptt.com