Advertisement
uzunovz

Softuniada 2017 - 03. Duplicated Letters

Jan 11th, 2017
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None
  1. import re
  2.  
  3. test_string = input()
  4.  
  5. regEx = '([a-z])\\1'
  6.  
  7. steps = 0
  8.  
  9. while len(list(re.findall(regEx, test_string))) != 0:
  10.     test_string = re.sub(regEx, '', test_string, 1)
  11.     steps += 1
  12.  
  13. if len(test_string) > 0:
  14.     print(test_string)
  15. else:
  16.     print("Empty String")
  17. print("{0} operations".format(steps))
Advertisement
RAW Paste Data Copied
Advertisement