Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def shiftMaxCharLeft(s):
- if len(s) <= 1:
- return s
- else:
- if shiftMaxCharLeft(s[:-1])[0] < s[-1]:
- return s[-1] + s[:-1]
- else:
- return shiftMaxCharLeft(s[:-1]) + s[-1]
- test_cases = ["acbxdyfjzdmk", "", "az", "a", "abcdefgh", "azbz"]
- for arg in test_cases:
- print(f"shiftMaxCharLeft({repr(arg)}) -> {repr(shiftMaxCharLeft(arg))}")
- #result:
- #shiftMaxCharLeft('acbxdyfjzdmk') -> 'zacbxdyfjdmk'
- #shiftMaxCharLeft('') -> ''
- #shiftMaxCharLeft('az') -> 'za'
- #shiftMaxCharLeft('a') -> 'a'
- #shiftMaxCharLeft('abcdefgh') -> 'habcdefg'
- #shiftMaxCharLeft('azbz') -> 'zabz'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement