Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def compress():
- texts = ["AndrzejAndrzej", "TomekTomek", "AndyAnd", "KamilKmail", "KasiaKasia"]
- for text in texts:
- if len(text) % 2 is 0:
- half = len(text) / 2
- if text[:half] == text[half:]:
- print "({0})".format(text[:half])
- def uncompress():
- uncompressed = ""
- group = ""
- texts = ["Anr(z)e(jek)", "(Ka)mil(os)", "Domi(nn)ik(awe)"]
- for text in texts:
- for i, c in enumerate(text):
- if c is not '(' and c is not ')':
- uncompressed += c
- if c is '(':
- while text[i+1] is not ')':
- group += text
- print uncompressed
- uncompressed = ""
- uncompress()
Advertisement
Add Comment
Please, Sign In to add comment