Advertisement
Guest User

Untitled

a guest
May 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. def shiftMaxCharLeft(s):
  2. if len(s) <= 1:
  3. return s
  4. else:
  5. if shiftMaxCharLeft(s[:-1])[0] < s[-1]:
  6. return s[-1] + s[:-1]
  7. else:
  8. return shiftMaxCharLeft(s[:-1]) + s[-1]
  9.  
  10. test_cases = ["acbxdyfjzdmk", "", "az", "a", "abcdefgh", "azbz"]
  11. for arg in test_cases:
  12. print(f"shiftMaxCharLeft({repr(arg)}) -> {repr(shiftMaxCharLeft(arg))}")
  13.  
  14. #result:
  15. #shiftMaxCharLeft('acbxdyfjzdmk') -> 'zacbxdyfjdmk'
  16. #shiftMaxCharLeft('') -> ''
  17. #shiftMaxCharLeft('az') -> 'za'
  18. #shiftMaxCharLeft('a') -> 'a'
  19. #shiftMaxCharLeft('abcdefgh') -> 'habcdefg'
  20. #shiftMaxCharLeft('azbz') -> 'zabz'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement