





_lowerCamelCase			       =      256
# Modulus to hash a string
_lowerCamelCase			       =      100_0003




def    __UpperCAmelCase(      lowercase_ ,    lowercase_      ):
							_lowerCamelCase							:     Tuple	=		len(lowercase_      )
							_lowerCamelCase							:     int	=		len(lowercase_      )
							if p_len > t_len:
														return False

							_lowerCamelCase							:     Union[str, Any]	=		0
							_lowerCamelCase							:     int	=		0
							_lowerCamelCase							:     Union[str, Any]	=		1

							# Calculating the hash of pattern and substring of text
							for i in range(lowercase_      ):
														_lowerCamelCase							:     List[str]	=		(ord(pattern[i]      ) + p_hash * alphabet_size) % modulus
														_lowerCamelCase							:     Tuple	=		(ord(text[i]      ) + text_hash * alphabet_size) % modulus
														if i == p_len - 1:
																					continue
														_lowerCamelCase							:     List[str]	=		(modulus_power * alphabet_size) % modulus

							for i in range(0 ,    t_len - p_len + 1      ):
														if text_hash == p_hash and text[i : i + p_len] == pattern:
																					return True
														if i == t_len - p_len:
																					continue
														# Calculate the https://en.wikipedia.org/wiki/Rolling_hash
														_lowerCamelCase							:     Optional[Any]	=		(
														    (text_hash - ord(text[i]      ) * modulus_power) * alphabet_size
														    + ord(text[i + p_len]      )
														) % modulus
							return False




def    __UpperCAmelCase(      ):
							_lowerCamelCase							:     List[Any]	=		'''abc1abc12'''
							_lowerCamelCase							:     str	=		'''alskfjaldsabc1abc1abc12k23adsfabcabc'''
							_lowerCamelCase							:     int	=		'''alskfjaldsk23adsfabcabc'''
							assert rabin_karp(lowercase_ ,    lowercase_      ) and not rabin_karp(lowercase_ ,    lowercase_      )

							# Test 2)
							_lowerCamelCase							:     List[Any]	=		'''ABABX'''
							_lowerCamelCase							:     Any	=		'''ABABZABABYABABX'''
							assert rabin_karp(lowercase_ ,    lowercase_      )

							# Test 3)
							_lowerCamelCase							:     str	=		'''AAAB'''
							_lowerCamelCase							:     Union[str, Any]	=		'''ABAAAAAB'''
							assert rabin_karp(lowercase_ ,    lowercase_      )

							# Test 4)
							_lowerCamelCase							:     Dict	=		'''abcdabcy'''
							_lowerCamelCase							:     int	=		'''abcxabcdabxabcdabcdabcy'''
							assert rabin_karp(lowercase_ ,    lowercase_      )

							# Test 5)
							_lowerCamelCase							:     List[str]	=		'''Lü'''
							_lowerCamelCase							:     Optional[Any]	=		'''Lüsai'''
							assert rabin_karp(lowercase_ ,    lowercase_      )
							_lowerCamelCase							:     List[Any]	=		'''Lue'''
							assert not rabin_karp(lowercase_ ,    lowercase_      )
							print('''Success.'''      )


if __name__ == "__main__":
							test_rabin_karp()








import unittest

from knapsack import knapsack as k







class 			__A       (      unittest.TestCase  ):




      """simple docstring"""







      def 				__snake_case			(		self):



             """simple docstring"""





             _lowerCamelCase							:     Dict	=		0
             _lowerCamelCase							:     int	=		[0]
             _lowerCamelCase							:     Optional[int]	=		[0]
             _lowerCamelCase							:     Dict	=		len(a__)
             self.assertEqual(k.knapsack(a__      ,							a__      ,							a__      ,							a__)      ,							0)

             _lowerCamelCase							:     str	=		[60]
             _lowerCamelCase							:     List[str]	=		[10]
             _lowerCamelCase							:     List[Any]	=		len(a__)
             self.assertEqual(k.knapsack(a__      ,							a__      ,							a__      ,							a__)      ,							0)


      def 				__snake_case			(		self):



             """simple docstring"""





             _lowerCamelCase							:     Union[str, Any]	=		3
             _lowerCamelCase							:     List[Any]	=		[1, 2, 3]
             _lowerCamelCase							:     Dict	=		[3, 2, 1]
             _lowerCamelCase							:     Any	=		len(a__)
             self.assertEqual(k.knapsack(a__      ,							a__      ,							a__      ,							a__)      ,							5)



      def 				__snake_case			(		self):



             """simple docstring"""





             _lowerCamelCase							:     Optional[Any]	=		50
             _lowerCamelCase							:     Dict	=		[60, 100, 120]
             _lowerCamelCase							:     Dict	=		[10, 20, 30]
             _lowerCamelCase							:     Union[str, Any]	=		len(a__)
             self.assertEqual(k.knapsack(a__      ,							a__      ,							a__      ,							a__)      ,							220)


if __name__ == "__main__":
       unittest.main()

