Guest User

Untitled

a guest
Sep 30th, 2020
58
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. n, m = [int(p) for p in input().split(' ')]
  3.  
  4. snake = input()
  5.  
  6. matrix = []
  7.  
  8. last_symbols = ""
  9. for i in range(n):
  10. matrix.append([])
  11. count = 0
  12. while len(matrix[i]) != m:
  13. if last_symbols:
  14. for char in last_symbols:
  15. if i % 2 != 0:
  16. matrix[i].insert(0, char)
  17. else:
  18. matrix[i].append(char)
  19. last_symbols = ""
  20. if i % 2 != 0:
  21. matrix[i].insert(0, snake[count])
  22. else:
  23. matrix[i].append(snake[count])
  24. count += 1
  25. if len(matrix[i]) == m:
  26. last_symbols = snake[count:]
  27.  
  28. for item in matrix:
  29. print("".join(item))
  30.  
RAW Paste Data