Advertisement
Guest User

tim_pa1

a guest
Jan 26th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. T = int(input())
  2.  
  3. i = 0
  4. while i < T:
  5. rcMN = input()
  6. # print(rcMN)
  7. r,c,M,N = rcMN.split() # splitting input
  8. G =[]
  9. j = 0
  10.  
  11. # arrange horizontally
  12. G1 = []
  13. for x in range(int(r)):
  14. line = input().split(" ")
  15. G1.append(line)
  16. # rotate
  17. G2 = []
  18. for x in range(len(G1)):
  19. G2a = G1[x][int(M)-1:] + G1[x][:int(M)-1] # slices the list at M
  20. G2.append(G2a)
  21. # arrange vertically
  22. """G3 = []
  23. for x in range(int(c)):
  24. newrow = []
  25. for y in range(int(r)):
  26. z = G2[y][x]
  27. newrow.append(int(z))
  28. G3.append(newrow) """
  29. # switcheroo
  30. G4 = []
  31. for x in range(len(G2)):
  32. G4a = G2[x][int(N):] + G2[x][:int(N)] # slices the string at M
  33. G4.append(G4a)
  34. #print(G4[2][0])
  35. #print(G4)
  36.  
  37. # arranging output
  38.  
  39. # traverse all sublists and append the kth element of each
  40.  
  41. c1 = 0
  42. while c1 < len(G4):
  43. newer_row = []
  44. c2 = 0
  45. while c2 < len(G4[c1]):
  46. newer_row.append(G4[c1][c2])
  47. c2 += 1
  48. print(newer_row)
  49. c1 += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement