Question
Convert the given word in to snaky conversion according to the number (N)
Example:-
Input
AWESOMENESS 4
Explanation:-
A. E
W. M. N
E. O. E. S
S. S
Output :-
AE
WMN
EOES
SS
s = input()
s, n = s.split()
n = int(n)
res = ["" for i in range(n)]
direction = 1
while s:
tmp = s[:n]
s = s[n:]
if direction == -1:
tmp = tmp[::-1]
for i in range(len(tmp)):
res[i] += tmp[i]
direction *= -1
print(*res, sep='\n')
Comments
Leave a comment