• API
• FAQ
• Tools
• Archive
SHARE
TWEET

05. Snake Moves

a guest Jan 24th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
2.     rows, cols = [int(num) for num in input().split()]
3.     _text = input()
4.
5.     _matrix = []
6.     for _ in range(rows):
7.         _matrix.append([" " for _ in range(cols)])
8.     return _matrix, _text
9.
10.
11. def fill_matrix(matrix, text):
12.     current_text = [letter for letter in text][::-1]
13.
14.     for row in range(len(matrix)):
15.         for col in range(len(matrix[0])):
16.             if current_text:
17.                 matrix[row][col] = current_text.pop()
18.             else:
19.                 current_text = [letter for letter in text][::-1]
20.                 matrix[row][col] = current_text.pop()
21.     for row in range(len(matrix)):  # Swapping the direction of each second row
22.         if row % 2 != 0:
23.             matrix[row] = matrix[row][::-1]
24.     return matrix
25.
26.
27. def print_matrix(matrix_to_print):
28.     for row in matrix_to_print:
29.         print(''.join(row))
30.
31.
32. def solve_snake_moves():