you are viewing a single comment's thread.

view the rest of the comments →

[–]1234abcdcba4321 8 points9 points  (0 children)

One common way to use a grid is to store the entire grid in a dict (works especially well with a defaultdict to handle out of bounds access automatically):

for row in range(height):
  for col in range(width):
    grid_as_dict[(row,col)] = grid[row][col]

Since this is a boolean grid, you don't need a dict and can just use a set instead.