Advertisement
viligen

snake_moves

Jan 23rd, 2022
796
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rows, cols = [int(n) for n in input().split()]
  2.  
  3. text = input()
  4. matrix = []
  5.  
  6. text_idx = 0
  7.  
  8. for row in range(rows):
  9.     current_row = [''] * cols
  10.     if row % 2 == 0:
  11.         for col in range(cols):
  12.             current_idx = text_idx % len(text)
  13.             current_row[col] = text[current_idx]
  14.             text_idx += 1
  15.  
  16.     else:
  17.         for col in range(cols - 1, -1, -1):
  18.             current_idx = text_idx % len(text)
  19.             current_row[col] = text[current_idx]
  20.             text_idx += 1
  21.     matrix.append(current_row)
  22. for r in range(rows):
  23.     print(*matrix[r], sep='')
  24.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement