





from random import randint, random





def      lowerCAmelCase_ (       __a	,    __a	,    __a	,    __a = False	,    __a = False	,    __a = 5	,    )     ->		list:







  """simple docstring"""





  lowerCamelCase__:      Tuple			  =[[-1] * number_of_cells]  # Create a highway without any car
  lowerCamelCase__:      Dict			  =0
  lowerCamelCase__:      Any			  =max(__a	,    0		)
  while i < number_of_cells:
    lowerCamelCase__:      str			  =(
        randint(0	,    __a		) if random_speed else initial_speed
    )  # Place the cars
    i += (
        randint(1	,    max_speed * 2		) if random_frequency else frequency
    )  # Arbitrary number, may need tuning
  return highway





def      lowerCAmelCase_ (       __a	,    __a		)     ->		int:







  """simple docstring"""





  lowerCamelCase__:      Optional[int]			  =0
  lowerCamelCase__:      Optional[int]			  =highway_now[car_index + 1 :]
  for cell in range(len(__a		)		):  # May need a better name for this
    if cells[cell] != -1:  # If the cell is not empty then
      return distance  # we have the distance we wanted
    distance += 1
  # Here if the car is near the end of the highway
  return distance + get_distance(__a	,    -1		)





def      lowerCAmelCase_ (       __a	,    __a	,    __a		)     ->		list:







  """simple docstring"""





  lowerCamelCase__:      Optional[int]			  =len(__a		)
  # Beforce calculations, the highway is empty
  lowerCamelCase__:      Dict			  =[-1] * number_of_cells

  for car_index in range(__a		):
    if highway_now[car_index] != -1:
      # Add 1 to the current speed of the car and cap the speed
      lowerCamelCase__:      int			  =min(highway_now[car_index] + 1	,    __a		)
      # Number of empty cell before the next car
      lowerCamelCase__:      Union[str, Any]			  =get_distance(__a	,    __a		) - 1
      # We can't have the car causing an accident
      lowerCamelCase__:      Dict			  =min(next_highway[car_index]	,    __a		)
      if random() < probability:
        # Randomly, a driver will slow down
        lowerCamelCase__:      int			  =max(next_highway[car_index] - 1	,    0		)
  return next_highway





def      lowerCAmelCase_ (       __a	,    __a	,    __a	,    __a		)     ->		list:







  """simple docstring"""





  lowerCamelCase__:      Dict			  =len(highway[0]		)

  for i in range(__a		):
    lowerCamelCase__:      Dict			  =update(highway[i]	,    __a	,    __a		)
    lowerCamelCase__:      List[str]			  =[-1] * number_of_cells

    for car_index in range(__a		):
      lowerCamelCase__:      Any			  =next_speeds_calculated[car_index]
      if speed != -1:
        # Change the position based on the speed (with % to create the loop)
        lowerCamelCase__:      Dict			  =(car_index + speed) % number_of_cells
        # Commit the change of position
        lowerCamelCase__:      Optional[Any]			  =speed
    highway.append(__a		)

  return highway


if __name__ == "__main__":
     import doctest

     doctest.testmod()








import os


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_doctest_list.py
__A									=				"."


if __name__ == "__main__":
     __A									=				os.path.join(REPO_PATH, "utils/documentation_tests.txt")
     __A									=				[]
     __A									=				[]
     with open(doctest_file_path) as fp:
          for line in fp:
               __A									=				line.strip()
               __A									=				os.path.join(REPO_PATH, line)
               if not (os.path.isfile(path) or os.path.isdir(path)):
                    non_existent_paths.append(line)
               all_paths.append(path)
     if len(non_existent_paths) > 0:
          __A									=				"\n".join(non_existent_paths)
          raise ValueError(f'`utils/documentation_tests.txt` contains non-existent paths:\n{non_existent_paths}')
     if all_paths != sorted(all_paths):
          raise ValueError("Files in `utils/documentation_tests.txt` are not in alphabetical order.")

