def A__  (			lowercase:     Tuple,		lowercase:     int					)				->		List[Any]:

       '''simple docstring'''





       A						:     int         =0
       A						:     str         =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

              A						:     List[str]         =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

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



def A__  (			lowercase:     Optional[Any],		lowercase:     Optional[int],		lowercase:     str,		lowercase:     Optional[int]					)				->		int:

       '''simple docstring'''





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

       A						:     Tuple         =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:     Tuple					)				->		Any:

       '''simple docstring'''





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


if __name__ == "__main__":
    import sys
    _lowercase							:      List[str]      							=0
    if debug == 1:
        _lowercase							:      Optional[int]      							=[1_0, 3_0, 4_0, 4_5, 5_0, 6_6, 7_7, 9_3]
        try:
            __assert_sorted(collection)
        except ValueError:
            sys.exit('''Sequence must be ascending sorted to apply interpolation search''')
        _lowercase							:      List[Any]      							=6_7

    _lowercase							:      Any      							=interpolation_search(collection, target)
    if result is not None:
        print(f'''{target} found at positions: {result}''')
    else:
        print('''Not found''')







def A__  (			lowercase:     int					)				->		int:
       if not isinstance(lowercase,		lowercase					) or number < 0:
              raise ValueError('Input must be a non-negative integer'					)

       A						:     Any         =0
       while number:
              # This way we arrive at next set bit (next 1) instead of looping
              # through each bit and checking for 1s hence the
              # loop won't run 32 times it will only run the number of `1` times
              number &= number - 1
              count += 1
       return count


if __name__ == "__main__":
    import doctest

    doctest.testmod()






