def sort_output(digit_chose):
digit_chose.sort(reverse = True)
num = 0
for each in digit_chose:
num = num * 10 + each
return num
def del_digit(original_digit, digit_chosen):
return list(set(original_digit) - set(digit_chosen))
dl = [4, 5, 6, 7, 8, 9]
former = 0
for i in range(4, 10):
for j in range(i, 10):
for k in range(j, 10):
if i != j and i != k & j != k:
digit_chosen = [i, j, k]
other_num = del_digit(dl, digit_chosen)
product = sort_output(digit_chosen) * sort_output(other_num)
if product > former:
former = product
factor1 = sort_output(digit_chosen)
factor2 = sort_output(other_num)
print('%d × %d = %d' %(factor1, factor2, former))
|