-
-
Save anonymous/5ce8e5d895ed8952fe4975c68e1b64c8 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
import re | |
import sys | |
from collections import deque | |
# удалить все пробелы | |
# 're que sts' -> 'requests' | |
s = re.sub(r'\s+', '', ''.join(sys.argv[1:])) | |
# https://ru.wikipedia.org/wiki/Двухсторонняя_очередь | |
# нужно для rotate, см. ниже | |
d = deque(s) | |
# проходит по каждому символу в строке, вращает деку на каждой итерации и join'ит результаты | |
# rotate(-1): requests -> equestr | |
# (join, rotate)[0] => join'им, вращаем и берем результат join'а | |
s = '\n'.join((' '.join(d), d.rotate(-1))[0] for _ in s) | |
print('[b]\n%s\n[/b]' % s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment