Matrix Rotation in Python?
So I got the following problem:
Given an image represented by an NxN matrix, where each pixel in the image is 4
bytes, write a method to rotate the image by 90 degrees.
The problem did not show sample input, so I had to infer some things, mainly the parameters. After a bit, I had the following:
def rotate(matrix):
rows = len(matrix)
columns = len(matrix[0])
for row in range(rows):
for column in range(columns // 2):
matrix[row][columns - 1 - column], matrix[row][column] = matrix[row][column], matrix[row][columns - 1 - column]
return matrix
My question is, does this implementation look correct? I receive the correct output when running some tests, but that doesn't really clarify the problem. Am I missing a piece of information from the question? I am asking because I did not use the "4 bytes long" piece of part of the exercise, which makes me concerned that I misunderstood the problem.
Clarifications are greatly appreciated
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector