



'''simple docstring'''




lowerCamelCase							:List[str]       = 2_5_6
# Modulus to hash a string
lowerCamelCase							:List[str]       = 1_0_0_0_0_0_3



def      a      (			lowerCamelCase__						,				lowerCamelCase__   ):
			'''simple docstring'''





			A_     :						Dict     =					len(lowerCamelCase__   )
			A_     :						Optional[int]     =					len(lowerCamelCase__   )
			if p_len > t_len:
						return False

			A_     :						Optional[Any]     =					0
			A_     :						Dict     =					0
			A_     :						Optional[int]     =					1

			# Calculating the hash of pattern and substring of text
			for i in range(lowerCamelCase__   ):
						A_     :						str     =					(ord(pattern[i]   ) + p_hash * alphabet_size) % modulus
						A_     :						Optional[Any]     =					(ord(text[i]   ) + text_hash * alphabet_size) % modulus
						if i == p_len - 1:
									continue
						A_     :						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
						A_     :						Union[str, Any]     =					(
						    (text_hash - ord(text[i]   ) * modulus_power) * alphabet_size
						    + ord(text[i + p_len]   )
						) % modulus
			return False



def      a      (			):
			'''simple docstring'''





			A_     :						Any     =					"""abc1abc12"""
			A_     :						Optional[int]     =					"""alskfjaldsabc1abc1abc12k23adsfabcabc"""
			A_     :						str     =					"""alskfjaldsk23adsfabcabc"""
			assert rabin_karp(lowerCamelCase__						,				lowerCamelCase__   ) and not rabin_karp(lowerCamelCase__						,				lowerCamelCase__   )

			# Test 2)
			A_     :						List[Any]     =					"""ABABX"""
			A_     :						Any     =					"""ABABZABABYABABX"""
			assert rabin_karp(lowerCamelCase__						,				lowerCamelCase__   )

			# Test 3)
			A_     :						List[Any]     =					"""AAAB"""
			A_     :						int     =					"""ABAAAAAB"""
			assert rabin_karp(lowerCamelCase__						,				lowerCamelCase__   )

			# Test 4)
			A_     :						str     =					"""abcdabcy"""
			A_     :						str     =					"""abcxabcdabxabcdabcdabcy"""
			assert rabin_karp(lowerCamelCase__						,				lowerCamelCase__   )

			# Test 5)
			A_     :						str     =					"""Lü"""
			A_     :						int     =					"""Lüsai"""
			assert rabin_karp(lowerCamelCase__						,				lowerCamelCase__   )
			A_     :						List[str]     =					"""Lue"""
			assert not rabin_karp(lowerCamelCase__						,				lowerCamelCase__   )
			print("""Success."""   )


if __name__ == "__main__":
						test_rabin_karp()




'''simple docstring'''




lowerCamelCase							:Any       = {
    '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''',
    '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '''N''': '''-.''',
    '''O''': '''---''', '''P''': '''.--.''', '''Q''': '''--.-''', '''R''': '''.-.''', '''S''': '''...''', '''T''': '''-''', '''U''': '''..-''',
    '''V''': '''...-''', '''W''': '''.--''', '''X''': '''-..-''', '''Y''': '''-.--''', '''Z''': '''--..''', '''1''': '''.----''',
    '''2''': '''..---''', '''3''': '''...--''', '''4''': '''....-''', '''5''': '''.....''', '''6''': '''-....''', '''7''': '''--...''',
    '''8''': '''---..''', '''9''': '''----.''', '''0''': '''-----''', '''&''': '''.-...''', '''@''': '''.--.-.''',
    ''':''': '''---...''', ''',''': '''--..--''', '''.''': '''.-.-.-''', '''\'''': '''.----.''', '''"''': '''.-..-.''',
    '''?''': '''..--..''', '''/''': '''-..-.''', '''=''': '''-...-''', '''+''': '''.-.-.''', '''-''': '''-....-''',
    '''(''': '''-.--.''', ''')''': '''-.--.-''', '''!''': '''-.-.--''', ''' ''': '''/'''
}  # Exclamation mark is not in ITU-R recommendation
# fmt: on
lowerCamelCase							:Any       = {value: key for key, value in MORSE_CODE_DICT.items()}



def      a      (			lowerCamelCase__   ):
			'''simple docstring'''





			return " ".join(MORSE_CODE_DICT[char] for char in message.upper()   )



def      a      (			lowerCamelCase__   ):
			'''simple docstring'''





			return "".join(REVERSE_DICT[char] for char in message.split()   )



def      a      (			):
			'''simple docstring'''





			A_     :						List[str]     =					"""Morse code here!"""
			print(lowerCamelCase__   )
			A_     :						str     =					encrypt(lowerCamelCase__   )
			print(lowerCamelCase__   )
			A_     :						Dict     =					decrypt(lowerCamelCase__   )
			print(lowerCamelCase__   )


if __name__ == "__main__":
						main()