# coding: utf-8
import copy
input_S =list(raw_input())
T = ""
reversed_S = copy.deepcopy(input_S)
reversed_S.reverse()
while(len(input_S)> 0):
if input_S < reversed_S:
T += input_S[0]
input_S = input_S[1:]
reversed_S= reversed_S[:-1]
else:
T += reversed_S[0]
input_S = input_S[:-1]
reversed_S= reversed_S[1:]
print T
It was unusual (for me) to write simpler than the answer example.
Recommended Posts