def run_len(grid, path, value):
  """Returns the number of continous elements along path that have value |value|"""
  num_matches = 0
  for point in path:
    if grid.at(point) is value:
      num_matches += 1
    else:
      break
  return num_matches