Skip to content

Instantly share code, notes, and snippets.

@glickmac
Created September 9, 2022 15:02
Show Gist options
  • Save glickmac/4a54c9707df309eb08b16775d1a7590e to your computer and use it in GitHub Desktop.
Save glickmac/4a54c9707df309eb08b16775d1a7590e to your computer and use it in GitHub Desktop.
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