Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. import re
  2.  
  3. def recurse(chunk,word):
  4.  
  5. rev_string = chunk[::-1]
  6. rev_regex = word[::-1]
  7.  
  8. trimmed = re.sub(rev_regex, '', rev_string)[::-1]
  9. # print final
  10. if trimmed != chunk:
  11. return recurse(trimmed, word)
  12. else:
  13. return trimmed
  14.  
  15.  
  16. def answer(chunk, word):
  17. print recurse(chunk, word)
  18. return recurse(chunk, word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement