'''simple docstring'''


from random import randint, random


def  _lowerCamelCase   (				lowerCamelCase_ :							int     ,					lowerCamelCase_ :							int     ,					lowerCamelCase_ :							int     ,					lowerCamelCase_ :							bool = False     ,					lowerCamelCase_ :							bool = False     ,					lowerCamelCase_ :							int = 5     ,					):



     """simple docstring"""





     UpperCAmelCase_							:       str       =				[[-1] * number_of_cells]  # Create a highway without any car
     UpperCAmelCase_							:       Dict       =				0
     UpperCAmelCase_							:       List[str]       =				max(lowerCamelCase_     ,					0       )
     while i < number_of_cells:
          UpperCAmelCase_							:       List[str]       =				(
              randint(0     ,					lowerCamelCase_       ) 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   (				lowerCamelCase_ :							list     ,					lowerCamelCase_ :							int       ):



     """simple docstring"""





     UpperCAmelCase_							:       Any       =				0
     UpperCAmelCase_							:       Union[str, Any]       =				highway_now[car_index + 1 :]
     for cell in range(len(lowerCamelCase_       )       ):  # 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(lowerCamelCase_     ,					-1       )


def  _lowerCamelCase   (				lowerCamelCase_ :							list     ,					lowerCamelCase_ :							float     ,					lowerCamelCase_ :							int       ):



     """simple docstring"""





     UpperCAmelCase_							:       List[Any]       =				len(lowerCamelCase_       )
     # Beforce calculations, the highway is empty
     UpperCAmelCase_							:       List[str]       =				[-1] * number_of_cells

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


def  _lowerCamelCase   (				lowerCamelCase_ :							list     ,					lowerCamelCase_ :							int     ,					lowerCamelCase_ :							float     ,					lowerCamelCase_ :							int       ):



     """simple docstring"""





     UpperCAmelCase_							:       Union[str, Any]       =				len(highway[0]       )

     for i in range(lowerCamelCase_       ):
          UpperCAmelCase_							:       int       =				update(highway[i]     ,					lowerCamelCase_     ,					lowerCamelCase_       )
          UpperCAmelCase_							:       Tuple       =				[-1] * number_of_cells

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

     return highway


if __name__ == "__main__":
 import doctest

 doctest.testmod()







'''simple docstring'''


def  _lowerCamelCase   (				lowerCamelCase_ :							int     ,					lowerCamelCase_ :							int       ):



     """simple docstring"""





     return int(input_a == input_a == 0       )


def  _lowerCamelCase   (				):



     """simple docstring"""





     print('Truth Table of NOR Gate:'       )
     print('|   Input 1   |  Input 2  | Output |'       )
     print(F'''|      0      |    0      |  {nor_gate(0     ,					0       )}     |'''       )
     print(F'''|      0      |    1      |  {nor_gate(0     ,					1       )}     |'''       )
     print(F'''|      1      |    0      |  {nor_gate(1     ,					0       )}     |'''       )
     print(F'''|      1      |    1      |  {nor_gate(1     ,					1       )}     |'''       )


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 main()






