2013-04-17 14:34:39 +08:00

32 lines
520 B
Python

def pick(x, lis, out, a = 0):
if x == 0:
out.append(a)
return
a *= 10
for i in xrange(len(lis)):
tmp = lis[:]
tmpa = a + lis[i]
tmp.pop(i)
pick(x - 1, tmp, out, tmpa)
def test(x):
mm = '932718654'
ss = ''
i = 0
while len(ss) < 9:
i += 1
ss += str(i * x)
tt = []
for j in xrange(len(ss)):
tt.append(ss[j])
if len(tt) == len(set(tt)) and ss >= mm:
if not tt.count('0'):
print ss
num = [1,2,3,4,5,6,7,8,9]
tt = []
pick(4, num, tt)
for i in tt:
test(i)