






from random import randint, random




def 					lowercase__				(					__snake_case   :							int					,	__snake_case   :							int					,	__snake_case   :							int					,	__snake_case   :							bool = False					,	__snake_case   :							bool = False					,	__snake_case   :							int = 5					,	):


					'''simple docstring'''


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


					'''simple docstring'''


					UpperCAmelCase_   :				Optional[int]						=						0
					UpperCAmelCase_   :				List[Any]						=						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 					lowercase__				(					__snake_case   :							list					,	__snake_case   :							float					,	__snake_case   :							int  ):


					'''simple docstring'''


					UpperCAmelCase_   :				str						=						len(__snake_case  )
					# Beforce calculations, the highway is empty
					UpperCAmelCase_   :				List[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
															UpperCAmelCase_   :				str						=						min(highway_now[car_index] + 1					,	__snake_case  )
															# Number of empty cell before the next car
															UpperCAmelCase_   :				Tuple						=						get_distance(__snake_case					,	__snake_case  ) - 1
															# We can't have the car causing an accident
															UpperCAmelCase_   :				Optional[int]						=						min(next_highway[car_index]					,	__snake_case  )
															if random() < probability:
																				# Randomly, a driver will slow down
																				UpperCAmelCase_   :				str						=						max(next_highway[car_index] - 1					,	0  )
					return next_highway




def 					lowercase__				(					__snake_case   :							list					,	__snake_case   :							int					,	__snake_case   :							float					,	__snake_case   :							int  ):


					'''simple docstring'''


					UpperCAmelCase_   :				List[Any]						=						len(highway[0]  )

					for i in range(__snake_case  ):
										UpperCAmelCase_   :				str						=						update(highway[i]					,	__snake_case					,	__snake_case  )
										UpperCAmelCase_   :				Any						=						[-1] * number_of_cells

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

					return highway


if __name__ == "__main__":
		import doctest

		doctest.testmod()











def 					lowercase__				(					__snake_case   :							int  ):


					'''simple docstring'''


					UpperCAmelCase_   :				Tuple						=						[1]

					UpperCAmelCase_	,  UpperCAmelCase_	,  UpperCAmelCase_   :				Tuple						=						0, 0, 0
					UpperCAmelCase_   :				Union[str, Any]						=						ugly_nums[ia] * 2
					UpperCAmelCase_   :				Tuple						=						ugly_nums[ia] * 3
					UpperCAmelCase_   :				Union[str, Any]						=						ugly_nums[ia] * 5

					for _ in range(1					,	__snake_case  ):
										UpperCAmelCase_   :				Tuple						=						min(__snake_case					,	__snake_case					,	__snake_case  )
										ugly_nums.append(__snake_case  )
										if next_num == next_a:
															ia += 1
															UpperCAmelCase_   :				Union[str, Any]						=						ugly_nums[ia] * 2
										if next_num == next_a:
															ia += 1
															UpperCAmelCase_   :				Any						=						ugly_nums[ia] * 3
										if next_num == next_a:
															ia += 1
															UpperCAmelCase_   :				List[str]						=						ugly_nums[ia] * 5
					return ugly_nums[-1]


if __name__ == "__main__":
		from doctest import testmod

		testmod(verbose=True)
		print(F'{ugly_numbers(200) = }')






