Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T = int(input())
- i = 0
- while i < T:
- rcMN = input()
- # print(rcMN)
- r,c,M,N = rcMN.split() # splitting input
- G =[]
- j = 0
- # arrange horizontally
- G1 = []
- for x in range(int(r)):
- line = input().split(" ")
- G1.append(line)
- # rotate
- G2 = []
- for x in range(len(G1)):
- G2a = G1[x][int(M)-1:] + G1[x][:int(M)-1] # slices the list at M
- G2.append(G2a)
- # arrange vertically
- """G3 = []
- for x in range(int(c)):
- newrow = []
- for y in range(int(r)):
- z = G2[y][x]
- newrow.append(int(z))
- G3.append(newrow) """
- # switcheroo
- G4 = []
- for x in range(len(G2)):
- G4a = G2[x][int(N):] + G2[x][:int(N)] # slices the string at M
- G4.append(G4a)
- #print(G4[2][0])
- #print(G4)
- # arranging output
- # traverse all sublists and append the kth element of each
- c1 = 0
- while c1 < len(G4):
- newer_row = []
- c2 = 0
- while c2 < len(G4[c1]):
- newer_row.append(G4[c1][c2])
- c2 += 1
- print(newer_row)
- c1 += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement