Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3.7
- # -*- coding: utf-8 -*import
- from _collections import deque
- rows, columns = map(int, input().split())
- snake_string = input()
- matrix = [[None] * columns for _ in range(rows)]
- snake = deque(snake_string)
- for x in range(rows):
- if x % 2 == 0:
- for y in range(columns):
- if not snake:
- snake = deque(snake_string)
- matrix[x][y] = snake.popleft()
- else:
- for y in range(columns -1, -1, -1):
- if not snake:
- snake = deque(snake_string)
- matrix[x][y] = snake.popleft()
- print('\n'.join([''.join([y for y in x]) for x in matrix]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement