fork(1) download
  1. def g(a,s,n=1):
  2. for c in s:
  3. b,n=((n,1),(-n,2*n))[c<'W']
  4. if a<-b:break
  5. a+=b
  6. print(a)
  7. return a
  8.  
  9. print(g(15,'LLLWLLLL'))
  10.  
Success #stdin #stdout 0.01s 7852KB
stdin
Standard input is empty
stdout
14
12
8
16
15
13
9
1
1