python计算一个算术题: [1,2,3,4,5]共5个数,组成的3位数乘以2位数,取最大值
#!/usr/bin/python
# -*- coding: UTF-8 -*-
x = [1,2,3,4,5]
result_old = 0
for a in x :
for b in x:
if b == a : continue
for c in x:
if c == a: continue
if c == b: continue
for d in x:
if d == a: continue
if d == b: continue
if d == c: continue
for e in x:
if e == a: continue
if e == b: continue
if e == c: continue
if e == d: continue
result_curr = (a*100 + b*10 + c) * (d*10 + e)
if result_old < result_curr:
result_old = result_curr
old_a = a
old_b = b
old_c = c
old_d = d
old_e = e
print("%r%r%r X %r%r = %d" % (old_a, old_b, old_c, old_d, old_e, result_old))