Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@montaro
Created March 8, 2015 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montaro/2d5c0fecf47c7faf3f61 to your computer and use it in GitHub Desktop.
Save montaro/2d5c0fecf47c7faf3f61 to your computer and use it in GitHub Desktop.
Image Rotator
__author__ = 'arefaey'
def rotate(image_matrix):
result = []
n = len(image_matrix)
for i in range(n):
new_row = []
for j in range(n):
new_row.append(image_matrix[n - j - 1][i])
result.append(new_row)
return result
m1 = [[1, 9, 17, 8], [3, 5, 8, 2], [4, 7, 19, 33], [5, 6, 2, 11]]
print(rotate(m1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment