Advertisement
davide1409

reverseRLE

Dec 8th, 2019
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. def reverseRLE(s):
  2. #@param s: str
  3. #@return str
  4.   new_str = ''  
  5.   jmp = 1
  6.   lung = len(s)
  7.   k = 1
  8.  
  9.   for i in range(lung):
  10.     if s[i] != ' ':
  11.       if not s[i].isdigit():
  12.         new_str+=s[i]
  13.    
  14.       else:
  15.         while s[i+k] == ' ' and i+k<lung:
  16.           jmp+=1
  17.           k+=1
  18.        
  19.         new_str+=(int(s[i])-1)*s[i+jmp]
  20.         jmp = 1
  21.         k = 1
  22.          
  23.          
  24.   return new_str
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement