Professional Documents
Culture Documents
Strength Reduction
Strength Reduction
Strength Reduction
a=[]
k=0
for i in range(n):
opr=b[i][0]
op1=b[i][1]
op2=b[i][2]
res=b[i][3]
if(opr=='^'):
k=int(op2)
x=['*',op1,op1,res]
a.append(x)
for j in range(0,k-2):
x=['*',op1,res,res]
a.append(x)
elif(opr=='*'):
k=int(op2)
x=['+',op1,op1,res]
a.append(x)
for j in range(0,k-2):
x=['+',op1,res,res]
a.append(x)
Page No.:
else:
a.append(b[i])
for i in a:
for j in i:
print(j,end=' ')
print('',sep='\n')
OUTPUT:
RESULT:
Page No.: