-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid_system.py
More file actions
30 lines (20 loc) · 737 Bytes
/
grid_system.py
File metadata and controls
30 lines (20 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def GridInit(grid_width, grid_height):
grid = [[0 for x in range(grid_width)] for y in range(grid_height)]
return grid
def Switch(grid, x, y):
newState = 0
if grid[x][y] == 0: newState = 1
elif grid[x][y] == 1: newState = 0
return newState
def IsGridEmpty(grid, grid_width, grid_height):
empty = True
for y in range(grid_height):
for x in range(grid_width):
if grid[x][y] == 1: empty = False
return empty
def main():
print("This is a library. It has:")
print(" - GridInit(grid_width, grid_height): Returns a 2D list filled with 0.")
print(" - Switch(grid_width, x, y): Retuns the inverted value of the cell.")
if __name__ == '__main__':
main()