Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:
h d
e l
l r
lowo
Input Specification:
Each input file contains one test case. Each case contains one string with no less than 5 and no more than 80 characters in a line. The string contains no white space.
Output Specification:
For each test case, print the input string in the shape of U as specified in the description.
解法
这道题挺智障的。。。因为n1和n3肯定是(len+2)//3,所以n2就定了。直接考虑打印效果即可。
s = input()
size = len(s)
d = (size + 2) // 3
w = size - 2 * d
for i in range(d - 1):
print(s[i] + w * ' ' + s[-1 * (i+1)])
print(s[d-1:d-1+w+2])