Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 07. Snake Moves
- # Multidimensional Lists - Exercise 1
- # https://judge.softuni.org/Contests/Practice/Index/1835#6
- from collections import deque
- size = input().split()
- n = int(size[0])
- m = int(size[1])
- word = input()
- snake = deque(word)
- matrix = []
- for row in range(n):
- matrix.append([])
- for col in range(m):
- letter_to_add = snake.popleft()
- matrix[row].append(letter_to_add)
- if not snake:
- snake = deque(word)
- counter = 0
- for sub_matrix in matrix:
- if counter % 2 == 0:
- print(''.join(sub_matrix))
- else:
- print(''.join(sub_matrix[::-1]))
- counter += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement