

# Algorithm for the pigeonhole sorting













def 			UpperCamelCase_(				_snake_case  :    Union[str, Any]      ):




			"""simple docstring"""






			__a     =min(__lowerCAmelCase      )  # min() finds the minimum value
			__a     =max(__lowerCAmelCase      )  # max() finds the maximum value

			__a     =max_val - min_val + 1  # size is difference of max and min values plus one

			# list of pigeonholes of size equal to the variable size
			__a     =[0] * size

			# Populate the pigeonholes.
			for x in a:
						assert isinstance(__lowerCAmelCase			,	__lowerCAmelCase      ), "integers only please"
						holes[x - min_val] += 1

			# Putting the elements back into the array in an order.
			__a     =0
			for count in range(__lowerCAmelCase      ):
						while holes[count] > 0:
									holes[count] -= 1
									__a     =count + min_val
									i += 1






def 			UpperCamelCase_(				):




			"""simple docstring"""






			__a     =[8, 3, 2, 7, 4, 6, 8]
			pigeonhole_sort(__lowerCAmelCase      )
			print('Sorted order is:'			,	' '.join(__lowerCAmelCase      )      )


if __name__ == "__main__":
						main()








def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    if any(not isinstance(__lowerCAmelCase     ,		__lowerCAmelCase				) or x < 0 for x in sequence				):
        raise TypeError("Sequence must be list of non-negative integers"				)
    for _ in range(len(__lowerCAmelCase				)				):
        for i, (rod_upper, rod_lower) in enumerate(zip(__lowerCAmelCase     ,		sequence[1:]				)				):
            if rod_upper > rod_lower:
                sequence[i] -= rod_upper - rod_lower
                sequence[i + 1] += rod_upper - rod_lower
    return sequence


if __name__ == "__main__":
     assert bead_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]
     assert bead_sort([7, 9, 4, 3, 5]) == [3, 4, 5, 7, 9]



