Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/f6e2f1634af16a391930f3f3db992854 to your computer and use it in GitHub Desktop.
Save completejavascript/f6e2f1634af16a391930f3f3db992854 to your computer and use it in GitHub Desktop.
while(1):
# Nhap so luong cot
num_col = int(raw_input())
if num_col == 0:
break
# Xau dau vao
str_input = raw_input()
# Tinh so luong cot
num_row = len(str_input) / num_col;
# Chuyen xau dau vao thanh dang ma tran
# va luu dang xau binh thuong
string = ""
for i in range(0, num_row):
if i % 2 == 0:
string += str_input[i*num_col : (i+1)*num_col]
else:
string += (str_input[i*num_col : (i+1)*num_col])[::-1]# dao nguoc xau
# xau ket qua
result = ""
for j in range(0, num_col):
for i in range(0, num_row):
result += string[i*num_col + j]
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment