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