PY
py
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
"""
[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!:-)
https://code.sololearn.com/WK4SG3ldwZuv/?ref=a
"""
#input:3 integer seperated by spaces
A = sorted(int(x) for x in input().split(' '))
max = '0'
for o1 in ('+','*'):
for o2 in ('+','*'):
expr='('+str(A[0])+o1+str(A[1])+')'+o2+str(A[2])
if eval(expr) > eval(max):
max = expr
print(max,'=',eval(max))
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run