LearnPy Hub
← Arena
IntermediateRating 1400

Zigzag Text

Write the string in a zigzag over r rows (down then diagonally up) and print the rows read left to right, joined. For PAYPALISHIRING and r = 3 the answer is PAHNAPLSIIGYIR.

Input

A string, then r ≥ 1.

Output

One line.

Sample 1

Input
PAYPALISHIRING
3
Output
PAHNAPLSIIGYIR

Sample 2

Input
PAYPALISHIRING
4
Output
PINALSIGYAHRPI
solution.py
Output appears here
Zigzag Text · Python Arena problem · LearnPy Hub