3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

蟻本をpythonで: page 45 辞書順最小の問題 (POJ3617)

Last updated at Posted at 2017-05-26

# 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

(自分としては)珍しく回答例よりシンプルに書けた。

3
3
8

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?