Answer to Question #198437 in Python for Hari nadh babu

Question #198437

In this Python code they were not getting expected output


M, N = input().split()
M, N = int(M), int(N)

matrix = []
for _ in range(M):
	row = [int(x) for x in input().split()]
	matrix.append(row)

K = int(input())

values = matrix[0][:-1] + [x[-1] for x in matrix][:-1] + matrix[-1][::-1][:-1] + [x[0] for x in matrix][::-1][:-1]

values = values[-K:] + values[:-K]

output = matrix

idxs = [(0, j) for j in range(N)][:-1] + [(i, N - 1) for i in range(M)][:-1] + [(M - 1, j) for j in range(N)][::-1][:-1] + [(i, 0) for i in range(M)][::-1][:-1]

idx = 0
for i, j in idxs:
	output[i][j] = values[idx]
	idx += 1

for i in output:
    for j in i:
      print(j, end=' ')
    print()

The test cases and outputs are in below url link

https://drive.google.com/file/d/1bi2pXd22sg9CeCnQp6SUzGOAsVpPguLi/view?usp=sharing


We need all test cases can be came when code was run. I want exact outputs for all test cases

1
Expert's answer
2021-05-25T10:49:12-0400
Dear Hari nadh babu, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS