





'''simple docstring'''

def    a__							(							lowercase   :	Dict,   lowercase   :	Optional[Any] )						->						int:





     """simple docstring"""

     _UpperCamelCase							       =			0
     _UpperCamelCase							       =			len(lowercase ) - 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							       =			left + ((item - sorted_collection[left]) * (right - left)) // (
              sorted_collection[right] - sorted_collection[left]
          )

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

          _UpperCamelCase							       =			sorted_collection[point]
          if current_item == item:
               return point
          else:
               if point < left:
                    _UpperCamelCase							       =			left
                    _UpperCamelCase							       =			point
               elif point > right:
                    _UpperCamelCase							       =			right
                    _UpperCamelCase							       =			point
               else:
                    if item < current_item:
                         _UpperCamelCase							       =			point - 1
                    else:
                         _UpperCamelCase							       =			point + 1
     return None







def    a__							(							lowercase   :	int,   lowercase   :	Optional[int],   lowercase   :	List[Any],   lowercase   :	List[Any] )						->						Dict:





     """simple docstring"""

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

     _UpperCamelCase							       =			left + ((item - sorted_collection[left]) * (right - left)) // (
         sorted_collection[right] - sorted_collection[left]
     )

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

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







def    a__							(							lowercase   :	Any )						->						List[Any]:





     """simple docstring"""

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


if __name__ == "__main__":
   import sys
   lowercase__		:     int			=							0
   if debug == 1:
      lowercase__		:     Optional[Any]			=							[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')
      lowercase__		:     List[str]			=							67

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






from __future__ import annotations

class     __snake_case    :
       """simple docstring"""







       def __init__(		self      , _UpperCamelCase      , _UpperCamelCase   )      ->							Tuple:






              """simple docstring"""


              __snake_case	,    __snake_case       	=							text, pattern
              __snake_case	,    __snake_case       	=							len(_UpperCamelCase   ), len(_UpperCamelCase   )


       def 			a		(		self      , _UpperCamelCase   )      ->							int:






              """simple docstring"""


              for i in range(self.patLen - 1      , -1      , -1   ):
                     if char == self.pattern[i]:
                            return i
              return -1


       def 			a		(		self      , _UpperCamelCase   )      ->							int:






              """simple docstring"""


              for i in range(self.patLen - 1      , -1      , -1   ):
                     if self.pattern[i] != self.text[current_pos + i]:
                            return current_pos + i
              return -1






       def 			a		(		self   )      ->							list[int]:






              """simple docstring"""


              __snake_case       	=							[]
              for i in range(self.textLen - self.patLen + 1   ):
                     __snake_case       	=							self.mismatch_in_text(_UpperCamelCase   )
                     if mismatch_index == -1:
                            positions.append(_UpperCamelCase   )
                     else:
                            __snake_case       	=							self.match_in_pattern(self.text[mismatch_index]   )
                            __snake_case       	=							(
                                mismatch_index - match_index
                            )  # shifting index lgtm [py/multiple-definition]
              return positions






UpperCamelCase__		 =     '''ABAABA'''
UpperCamelCase__		 =     '''AB'''
UpperCamelCase__		 =     BoyerMooreSearch(text, pattern)
UpperCamelCase__		 =     bms.bad_character_heuristic()

if len(positions) == 0:
    print('''No match found''')
else:
    print('''Pattern found in following positions: ''')
    print(positions)

