Created
July 16, 2014 17:06
-
-
Save ana0/352cd80472afe699faec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clockwise_rotation(grid): | |
#returns a representation of the grid rotated clockwise | |
rotated = [["" for i in grid] for i in grid] | |
l = len(grid) | |
for r in range(l): | |
x = l - r | |
for c in range(l): | |
rotated[r][c] = grid[x-1][r] | |
return rotated | |
def counterclockwise_rotation(grid): | |
#returns a representation of what you'd get if you rotated the grid 90 degress counterclockwise | |
rotated = [["" for i in grid] for i in grid] | |
l = len(grid) | |
for r in range(l): | |
for c in range(l): | |
x = l - r | |
rotated[r][c] = grid[c][x-1] | |
return rotated | |
def horizontal_flip(grid): | |
#returns a representation of what you'd get if you flipped the grid horizontally | |
rotated = [["" for i in grid] for i in grid] | |
l = len(grid) | |
for r in range(l): | |
for c in range(l): | |
x = l - c | |
rotated[r][c] = grid[c][x-1] | |
return rotated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment