Skip to content

Instantly share code, notes, and snippets.

@rupalbarman
Created May 30, 2017 05:18
Show Gist options
  • Save rupalbarman/d58532101beddfaa38316c2c8eb64da6 to your computer and use it in GitHub Desktop.
Save rupalbarman/d58532101beddfaa38316c2c8eb64da6 to your computer and use it in GitHub Desktop.
matrix rotation (layer wise) anti clockwise by 90 degrees
a= [
[1,2,3,4],
[5,6,7,8],
[9,10,11,12],
[13,14,15,16]
]
for _ in a:
print(*_)
print()
ab= [x[::-1] for x in zip(*a)]
ba= list(reversed([list(reversed(x)) for x in ab]))
for _ in ba:
print(*_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment