

'''simple docstring'''

from random import randint, random





def    A_  ( snake_case      ,       snake_case      ,       snake_case      ,       snake_case = False      ,       snake_case = False      ,       snake_case = 5      ,       ):
  SCREAMING_SNAKE_CASE:List[str]						      =					[[-1] * number_of_cells]  # Create a highway without any car
  SCREAMING_SNAKE_CASE:str						      =					0
  SCREAMING_SNAKE_CASE:Tuple						      =					max(snake_case      ,       0 )
  while i < number_of_cells:
    SCREAMING_SNAKE_CASE:Optional[Any]						      =					(
        randint(0      ,       snake_case ) 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    A_  ( snake_case      ,       snake_case ):
  SCREAMING_SNAKE_CASE:List[str]						      =					0
  SCREAMING_SNAKE_CASE:Optional[int]						      =					highway_now[car_index + 1 :]
  for cell in range(len(snake_case ) ):  # 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(snake_case      ,       -1 )





def    A_  ( snake_case      ,       snake_case      ,       snake_case ):
  SCREAMING_SNAKE_CASE:List[Any]						      =					len(snake_case )
  # Beforce calculations, the highway is empty
  SCREAMING_SNAKE_CASE:Optional[Any]						      =					[-1] * number_of_cells

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





def    A_  ( snake_case      ,       snake_case      ,       snake_case      ,       snake_case ):
  SCREAMING_SNAKE_CASE:Any						      =					len(highway[0] )

  for i in range(snake_case ):
    SCREAMING_SNAKE_CASE:Optional[Any]						      =					update(highway[i]      ,       snake_case      ,       snake_case )
    SCREAMING_SNAKE_CASE:Any						      =					[-1] * number_of_cells

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

  return highway


if __name__ == "__main__":
    import doctest

    doctest.testmod()









'''simple docstring'''

def    A_  ( snake_case ):
  SCREAMING_SNAKE_CASE:Dict						      =					(1 + 24 * n) ** 0.5
  return ((1 + root) / 6) % 1 == 0





def    A_  ( snake_case = 5000 ):
  SCREAMING_SNAKE_CASE:int						      =					[(i * (3 * i - 1)) // 2 for i in range(1      ,       snake_case )]
  for i, pentagonal_i in enumerate(snake_case ):
    for j in range(snake_case      ,       len(snake_case ) ):
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_nums[j]
      SCREAMING_SNAKE_CASE:Any						      =					pentagonal_i + pentagonal_j
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_j - pentagonal_i
      if is_pentagonal(snake_case ) and is_pentagonal(snake_case ):
        return b

  return -1


if __name__ == "__main__":
    print(f'''{solution() = }''')






