Skip to content

Commit 65cc081

Browse files
authored
Add files via upload
05
1 parent b472995 commit 65cc081

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

PythonTries/1835_05_SnakeMoves.py

+27
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)