def traverse_grid(start_cell, direction, num_steps):
    """
    Helper function that iterates over the cells
    in a grid in a linear direction and returns
    a list of their indices.
    """
    indices = list()
    for step in range(num_steps):
        row = start_cell[0] + step * direction[0]
        col = start_cell[1] + step * direction[1]
        indices.append((row, col))
    return indices