maximize product of two numbers formed with the digits $1$ to $9$

You are given the digits from $1$ to $9$. You can form two numbers by concatenating them, for example, $975123$ and $864$, and then take the product of the two resulting numbers. Find how to maximize the product.

To give you a hint, the answer is $87531\cdot9642$.

-

1 Answer

You could simply try them all. Since the digits should be listed in decreasing order from left to right, there are only 512 possibilities to check. In Mathematica,

possibilities = Map[FromDigits[Reverse[#]] &,
{#, Complement[Range[9], #]} & /@ Subsets[Range[9]], {2}];
First[Reverse[SortBy[{#, Times @@ #} & /@ possibilities, Last]]]


{{87531, 9642}, 843973902}

-
surely I wanted an analytic solution. :) – Qiang Li Jan 11 '12 at 22:10
Well, the problem looks very Project Euler-ish where the objective is to find a solution using a combination of programming and cleverness. – Mark McClure Jan 11 '12 at 22:14
I agree. But the result looks very informative in the sense that there is some rule here. But I am not sure how to formulate. – Qiang Li Jan 12 '12 at 1:06