Created
July 11, 2014 15:55
-
-
Save ana0/a2dca0394f154a09956e 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 create_grid(x): | |
#creates nested set of lists that represent a grid matrix | |
gridarray = [[i for i in range(x)] for i in range(x)] | |
return gridarray | |
def rotate_grid_counterclockwise(grid): | |
#returns a representation of what you'd get if you rotated the matrix 90 degress counterclockwise | |
rotated = [["" for i in grid] for i in grid] | |
x = len(grid) | |
r = 0 | |
for row in grid: | |
c = 0 | |
for column in row: | |
rotated[r][c] = grid[c][x-1] | |
c += 1 | |
r += 1 | |
x -= 1 | |
return rotated | |
def print_grid(grid): | |
#pretty printing for matrices | |
for i in grid: | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment