





'''simple docstring'''




def _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase    )->     str:
 __UpperCAmelCase					=   0
 __UpperCAmelCase					=   len(_lowerCAmelCase    ) - 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(_lowerCAmelCase    ):
   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 _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase       ,    _lowerCAmelCase       ,    _lowerCAmelCase    )->     Tuple:

 # 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(_lowerCAmelCase    ):
  return None

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







def _lowerCAmelCase     (      _lowerCAmelCase    )->     Optional[Any]:
 if collection != sorted(_lowerCAmelCase    ):
  raise ValueError('Collection must be ascending sorted'    )
 return True


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

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












'''simple docstring'''




from collections.abc import Sequence







def _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase    )->     float:
 return sum(c * (x**i) for i, c in enumerate(_lowerCAmelCase    )    )







def _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase    )->     float:
 __UpperCAmelCase					=   0.0
 for coeff in reversed(_lowerCAmelCase    ):
  __UpperCAmelCase					=   result * x + coeff
 return result


if __name__ == "__main__":
    _A:					str							=				(0.0, 0.0, 5.0, 9.3, 7.0)
    _A:					Dict							=				10.0
    print(evaluate_poly(poly, x))
    print(horner(poly, x))





