10344 - 23 out of 5


Difficulty : easy

Solution Description :

Combination  problem

a1 can be swapped with a2, a3 with a4, and so on. 
So, for rearranging the operands (a1, a2, a3, a4, a5) you need 5! = 120 possible combination. 

Operators can be either +,-,or *, and there are 4 place for put the operators.
So, there are only 3^4 = 81 possible combinations for rearranging the operators (+,-,*).

So you need calculate the expression result maximum (120*81) times.

use 4 inner loop for operators (+,-,*) and in the last loop you need permutation of 5 numbers.

For each combination,
if the expression result is 23, then output "Possible", otherwise output "Impossible".

Example:
1 2 4 5 7 => (((1 + 5) - 2) * 4) + 7 = ((6 - 2) * 4) + 7 = (4 * 4) + 7 = 16 + 7 = 23, Possible