code: def flatten_array(grid):
      
      grid = [grid[i][j] for i in range(len(grid)) for j in range(len(grid[i]))]
      while type(grid[0]) is list:
          grid = flatten_array(grid)
      return grid
docs: Takes a multi-dimensional array and returns a 1 dimensional array with the
      same contents.