KT
kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Created for Danijel Ivanović's question:
https://www.sololearn.com/Discuss/1290427
[ASSIGNMENT] : Expressions Matter
TASK : Given three integers a, b, c,
return the largest number obtained after inserting the following operators and brackets +, *, ( )
For Example : :
1. expressionsMatter(1,2,3) --> return 9
After placing signs and brackets, the Maximum value obtained from the expression is (1+2) * 3 = 9
2. expressionsMatter(9,1,1) --> return 18
After placing signs and brackets, the Maximum value obtained from the expression is 9 * (1+1) = 18
HappyCodings!:-)
*/
// Figure out which combination has the largest
// result. Try both the plus and star on either
// side of the second number. For both of those
// combinations, put the parentheses around both
// the addition and multiplication. Also, try adding
// or multiplying all 3 numbers. Making a total of
// 6 expressions to evalulate.
fun process(nums: List<Int>): Int {
// Calculate each expression.
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run