Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
519 B
0
Indexable
Never
import math

n = int(input())

for _ in range(n):
    word = input()
    rowLength = int(math.sqrt(len(word)))
    rows = []
    for rowIndex in range(rowLength):
        row = ""
        for columnIndex in range(rowLength):
            index = rowLength * rowIndex + columnIndex
            letter = word[index]
            row += letter
        rows.append(row[::-1])
    
    TransRows = [*zip(*rows)]
    message = ""
    for x in TransRows:
        for letter in x:
            message += letter
    print(message)