We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b472995 commit 65cc081Copy full SHA for 65cc081
PythonTries/1835_05_SnakeMoves.py
@@ -0,0 +1,27 @@
1
+def main():
2
+ first_line = input().split(" ")
3
+ rows = int(first_line[0])
4
+ columns = int(first_line[1])
5
+
6
+ snake = list(input())
7
+ snake_size = len(snake)
8
+ matrix = [[None for c in range(columns)] for r in range(rows)]
9
+ current_position = 0
10
+ is_reversed = True
11
12
+ for r in range(rows):
13
+ is_reversed = not is_reversed
14
+ for c in range(columns):
15
+ matrix[r][c] = snake[current_position % snake_size]
16
+ current_position += 1
17
+ if is_reversed:
18
+ matrix[r].reverse()
19
20
+ print(format_matrix(matrix))
21
22
23
+def format_matrix(my_matrix):
24
+ return '\n'.join(''.join(str(column) for column in row) for row in my_matrix)
25
26
+if __name__ == "__main__":
27
+ main()
0 commit comments