Advertisement
Guest User

Untitled

a guest
Jan 24th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. c=input()
  2. a=[0]
  3. s=0
  4. i=0
  5. def g(i,n):
  6.  p=i
  7.  if n:i+=1
  8.  while c[i].isdigit():i+=1
  9.  a[s]=int(c[p:i]);return i-1
  10. def e():
  11.  a.pop(s);s-=1
  12. while i<len(c):
  13.  d=c[i]
  14.  if d.isdigit():i=g(i,0)
  15.  elif d=='c':s+=1;a.insert(s,0)
  16.  elif d=='d':e()
  17.  elif d=='+':s+=1
  18.  elif d=='-':
  19.   if c[i+1].isdigit():i=g(i,1)
  20.   else:s-=1
  21.  elif d=='o':print(a[s],end=' ')
  22.  elif d=='?':
  23.   if a[s]==0:e()
  24.  elif d=='#':
  25.   if a[s]==0:i+=1
  26.  i+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement