


'''simple docstring'''
def 			a      (			__a ,					__a   )  ->	List[Any]:



					'''simple docstring'''






					UpperCamelCase__   :Tuple												= 0
					UpperCamelCase__   :Any												= len(__a   ) - 1

					while left <= right:
										# avoid divided by 0 during interpolation
										if sorted_collection[left] == sorted_collection[right]:
															if sorted_collection[left] == item:
																				return left
															else:
																				return None

										UpperCamelCase__   :Optional[int]												= left + ((item - sorted_collection[left]) * (right - left)) // (
										    sorted_collection[right] - sorted_collection[left]
										)

										# out of range check
										if point < 0 or point >= len(__a   ):
															return None

										UpperCamelCase__   :Optional[Any]												= sorted_collection[point]
										if current_item == item:
															return point
										else:
															if point < left:
																				UpperCamelCase__   :Dict												= left
																				UpperCamelCase__   :str												= point
															elif point > right:
																				UpperCamelCase__   :Any												= right
																				UpperCamelCase__   :int												= point
															else:
																				if item < current_item:
																									UpperCamelCase__   :int												= point - 1
																				else:
																									UpperCamelCase__   :int												= point + 1
					return None


def 			a      (			__a ,					__a ,					__a ,					__a   )  ->	int:



					'''simple docstring'''






					if sorted_collection[left] == sorted_collection[right]:
										if sorted_collection[left] == item:
															return left
										else:
															return None

					UpperCamelCase__   :Any												= left + ((item - sorted_collection[left]) * (right - left)) // (
					    sorted_collection[right] - sorted_collection[left]
					)

					# out of range check
					if point < 0 or point >= len(__a   ):
										return None

					if sorted_collection[point] == item:
										return point
					elif point < left:
										return interpolation_search_by_recursion(__a ,					__a ,					__a ,					__a   )
					elif point > right:
										return interpolation_search_by_recursion(__a ,					__a ,					__a ,					__a   )
					else:
										if sorted_collection[point] > item:
															return interpolation_search_by_recursion(
															    __a ,					__a ,					__a ,					point - 1   )
										else:
															return interpolation_search_by_recursion(
															    __a ,					__a ,					point + 1 ,					__a   )


def 			a      (			__a   )  ->	List[str]:



					'''simple docstring'''






					if collection != sorted(__a   ):
										raise ValueError('''Collection must be ascending sorted'''   )
					return True


if __name__ == "__main__":
		import sys
		__snake_case							      =     0
		if debug == 1:
				__snake_case							      =     [10, 30, 40, 45, 50, 66, 77, 93]
				try:
						__assert_sorted(collection)
				except ValueError:
						sys.exit('''Sequence must be ascending sorted to apply interpolation search''')
				__snake_case							      =     67

		__snake_case							      =     interpolation_search(collection, target)
		if result is not None:
				print(F"""{target} found at positions: {result}""")
		else:
				print('''Not found''')



'''simple docstring'''
from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream
class    lowercase	(							A__					):

		"""simple docstring"""

		def __init__(		self    ,   UpperCamelCase_    ,   UpperCamelCase_ = None    ,   UpperCamelCase_ = None    ,   UpperCamelCase_ = False    ,   UpperCamelCase_ = False    ,   UpperCamelCase_ = None    ,   UpperCamelCase_ = None    ,   **UpperCamelCase_    ,   ):

							'''simple docstring'''


							super().__init__(
							    features=UpperCamelCase_    ,   cache_dir=UpperCamelCase_    ,   keep_in_memory=UpperCamelCase_    ,   streaming=UpperCamelCase_    ,   num_proc=UpperCamelCase_    ,   **UpperCamelCase_    ,   )
							UpperCamelCase__   :Any												= Generator(
							    cache_dir=UpperCamelCase_    ,   features=UpperCamelCase_    ,   generator=UpperCamelCase_    ,   gen_kwargs=UpperCamelCase_    ,   **UpperCamelCase_    ,   )




		def     lowerCAmelCase__				(		self							):

							'''simple docstring'''


							if self.streaming:
												UpperCamelCase__   :Optional[Any]												= self.builder.as_streaming_dataset(split='''train'''							)
							# Build regular (map-style) dataset
							else:
												UpperCamelCase__   :Optional[int]												= None
												UpperCamelCase__   :int												= None
												UpperCamelCase__   :Any												= None
												UpperCamelCase__   :Any												= None

												self.builder.download_and_prepare(
												    download_config=UpperCamelCase_    ,   download_mode=UpperCamelCase_    ,   verification_mode=UpperCamelCase_    ,   base_path=UpperCamelCase_    ,   num_proc=self.num_proc    ,   )
												UpperCamelCase__   :List[Any]												= self.builder.as_dataset(
												    split='''train'''    ,   verification_mode=UpperCamelCase_    ,   in_memory=self.keep_in_memory							)
							return dataset