


'''simple docstring'''






from __future__ import annotations




class 	a       :
 def __init__(	self ,			__magic_name__ ,			__magic_name__  )   ->							int:
      _a ,				_a      =							text, pattern
      _a ,				_a      =							len(__magic_name__  ), len(__magic_name__  )
 def 							__UpperCAmelCase						(	self ,			__magic_name__  )   ->							int:

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

      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 							__UpperCAmelCase						(	self  )   ->							list[int]:
      # searches pattern in text and returns index positions
      _a      =							[]
      for i in range(self.textLen - self.patLen + 1  ):
           _a      =							self.mismatch_in_text(__magic_name__  )
           if mismatch_index == -1:
                positions.append(__magic_name__  )
           else:
                _a      =							self.match_in_pattern(self.text[mismatch_index]  )
                _a      =							(
                    mismatch_index - match_index
                )  # shifting index lgtm [py/multiple-definition]
      return positions





a_   :      Optional[Any]				    =      "ABAABA"
a_   :      Optional[Any]				    =      "AB"
a_   :      str				    =      BoyerMooreSearch(text, pattern)
a_   :      List[str]				    =      bms.bad_character_heuristic()

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





'''simple docstring'''






from timeit import timeit






def 		_A			(lowerCAmelCase__					:int						)				->					int:




     '''simple docstring'''



     if number < 0:
          raise ValueError('the value of input must not be negative'						)
     _a      =							0
     while number:
          number &= number - 1
          result += 1
     return result






def 		_A			(lowerCAmelCase__					:int						)				->					int:




     '''simple docstring'''



     if number < 0:
          raise ValueError('the value of input must not be negative'						)
     _a      =							0
     while number:
          if number % 2 == 1:
               result += 1
          number >>= 1
     return result






def 		_A			()				->					None:




     '''simple docstring'''



     def do_benchmark(lowerCAmelCase__					:int						) -> None:
          _a      =							'import __main__ as z'
          print(f'Benchmark when {number = }:'						)
          print(f'{get_set_bits_count_using_modulo_operator(lowerCAmelCase__						) = }'						)
          _a      =							timeit('z.get_set_bits_count_using_modulo_operator(25)'			,  setup=lowerCAmelCase__						)
          print(f'timeit() runs in {timing} seconds'						)
          print(f'{get_set_bits_count_using_brian_kernighans_algorithm(lowerCAmelCase__						) = }'						)
          _a      =							timeit(
              'z.get_set_bits_count_using_brian_kernighans_algorithm(25)'			,  setup=lowerCAmelCase__			,  )
          print(f'timeit() runs in {timing} seconds'						)

     for number in (25, 37, 58, 0):
          do_benchmark(lowerCAmelCase__						)
          print()


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 benchmark()

