






'''simple docstring'''




from __future__ import annotations

from random import choice

def 	__UpperCAmelCase       ( __magic_name__						)->    Dict:



			"""simple docstring"""



			return choice(__magic_name__						)

def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__						)->    int:



			"""simple docstring"""



			snake_case_				:					Optional[int]   =       random_pivot(__magic_name__						)

			# partition based on pivot
			# linear time
			snake_case_				:					Union[str, Any]   =       [e for e in lst if e < pivot]
			snake_case_				:					Union[str, Any]   =       [e for e in lst if e > pivot]

			# if we get lucky, pivot might be the element we want.
			# we can easily see this:
			# small (elements smaller than k)
			# + pivot (kth element)
			# + big (elements larger than k)
			if len(__magic_name__						) == k - 1:
						return pivot
			# pivot is in elements bigger than k
			elif len(__magic_name__						) < k - 1:
						return kth_number(__magic_name__     ,k - len(__magic_name__						) - 1						)
			# pivot is in elements smaller than k
			else:
						return kth_number(__magic_name__     ,__magic_name__						)


if __name__ == "__main__":
		import doctest

		doctest.testmod()












'''simple docstring'''




def 	__UpperCAmelCase       ( __magic_name__						)->    list[int]:



			"""simple docstring"""



			if length <= 0 or not isinstance(__magic_name__     ,__magic_name__						):
						raise ValueError("Length must be a positive integer."						)
			return [n * (2 * n - 1) for n in range(__magic_name__						)]


if __name__ == "__main__":
		print(hexagonal_numbers(length=5))
		print(hexagonal_numbers(length=10))




