I asked the following question on Facebook:
You have four numbers. You want to plug them into the equation a^b^c^d (where ^ is the exponentiation operator) to give the largest possible answer. Without doing the calculation, how do you sort them to guarantee (or at least make it more likely) that the result will be the largest possible answer?
So for example, assume a less complex question with two numbers, a^b. If your numbers are 3 and 2, then 3^2 gives a better answer than 2^3 [9 > 8], so one might guess that sorting the numbers in reverse, highest first, is the key. However, given 2 and 5, 2^5 is greater than 5^2 [32 > 25], so that doesn’t work. Perhaps there’s some threshold or formula that can be applied?
Assume that the exponentiation operator is left-associative (which it is on the Windows calculator, though not in most programming languages). That means x^y^z is equal to (x^y)^z, not x^(y^z).
Is there an algorithm that will produce the best results, or is it entirely dependent on the individual numbers?
Nobody came up with an answer, so I decided to write something to work it out. Here’s a script, written in PHP because it’s what I had to hand, that goes through all the values from 1 to 9 for a, b, c and d and permutes them into every unique arrangement, and then does the calculation and chooses the arrangements that give the largest result.
The result is here, but I have to say I have no idea what if any pattern there is…