Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = input()
- r=''
- w=''
- for i in a:
- if i.isalpha()==1:
- r+=i
- elif i.isdigit()==1 and (w=='' or w[len(w)-1]=='('):
- w+=i
- elif i.isdigit()==1 and w!='':
- if w[len(w)-1]<i:
- w+=i
- else:
- t=w[::-1]
- r += t[0]
- t = t[1:len(t)]
- while(1):
- if (len(t)==0 or t[0]<i or t[0]=='('):
- break
- else:
- r+=t[0]
- t = t[1:len(t)]
- w=t[::-1]
- w+=i
- elif i=='(':
- w+=i
- elif i==')':
- t=w[::-1]
- while(t[0]!='('):
- r+=t[0]
- t=t[1:len(t)]
- t=t[1:len(t)]
- w=t[::-1]
- t=w[::-1]
- while(len(t)!=0):
- r+=t[0]
- t=t[1:len(t)]
- print(r)
Add Comment
Please, Sign In to add comment