Created
September 9, 2022 15:02
-
-
Save glickmac/4a54c9707df309eb08b16775d1a7590e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = input() | |
words = list(a) | |
bwt = [] | |
for i in range(len(words)): | |
word = a[-1] + a[:-1] | |
new = ''.join(word) | |
a = new | |
bwt.append(new) | |
i += 1 | |
sort = sorted(bwt) | |
print(sort) | |
output = [] | |
for i in range(len(words)): | |
element = sort[i] | |
last = element[-1] | |
i = i + 1 | |
output.append(last) | |
print("".join(output)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment