이중 반복문을 통해서 주어진 단어를 세 부분으로 나눈 다음 [::-1]을 통해 뒤집고 단어를 모두 합쳐 리스트에 저장하여 리스트를 오름차순으로 정렬한 다음 맨 처음 나오는 요소를 출력하도록 코드를 작성했다. 그리 어렵진 않았다.
word = input()
lst = []
for i in range(1, len(word)-1):
for j in range(i+1, len(word)):
result = ""
first_part = word[:i][::-1]
second_part = word[i:j][::-1]
third_part = word[j:][::-1]
result += first_part + second_part + third_part
lst.append(result)
lst = sorted(lst)
print(lst[0])