2

There is a list of digits, lets say:

"1", "1", "9", "9"

And a multiply operator; how to make the max product. The answer for above example is:

91 * 91 = 8281

I find this post by Fawn, but cannot generalize to other examples. Is it correct?

for list B:

B = 9 9 9 8 8 8 8 7 7 7 7 6 6

The answer is $998776$ and $9888776$, and Fawn approach does not work there.

This post provide solution when there is no duplicate digit.

  • 1
    It's a list of digits, not numbers; you're using them as digits (concatenating them), not as numbers. – joriki Aug 31 '18 at 13:24
  • The answer by kba on this post solves your problem. https://math.stackexchange.com/questions/18560/maximize-a-b-times-c – Jan Aug 31 '18 at 13:33
  • His idea is to keep two number close to each other. 998876 and 9887776 are closer and product is 9876662139776. While 998776 * 9888776 = 9876672138176, which is bigger. – Aryan Firouzian Aug 31 '18 at 13:48
  • @AryanFirouzian It was meant to be implied that the algorithm only worked if you also the sum of the numbers (as also confirmed by Ross in his answer). But you are indeed right – there is an issue with my answer, but the issue is in how I distributed the numbers. You shouldn't just add to the smallest number. – kba Sep 04 '18 at 17:09

1 Answers1

1

You want the big digits leading and the two numbers as close to each other as possible. If the total number of digits is even the two numbers will each get half the digits. Sort the digits and distribute them in pairs between the two numbers. As soon as you have a difference, the one that got the larger of a pair gets the smaller of all subsequent pairs. If your digits were $9,9,9,8,8,8,7,6,5,4$ you would start with $99****$ and $98****$. The larger of each subsequent pair goes to the $98$ so you get $99864$ and $98875$

If the number of digits is odd you do the same, but the first discrepancy goes in favor of the shorter number, then all the rest go to the longer. This says $9,9,9,8,7,6,5,4,3$ would be split $9964$ and $98753$

Ross Millikan
  • 374,822