
__magic_name__  							=	256
# Modulus to hash a string
__magic_name__  							=	1_000_003





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase     ,		__lowerCAmelCase				):
    snake_case__    =					len(__lowerCAmelCase				)
    snake_case__    =					len(__lowerCAmelCase				)
    if p_len > t_len:
        return False

    snake_case__    =					0
    snake_case__    =					0
    snake_case__    =					1

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





def 						SCREAMING_SNAKE_CASE__     (   ):
    snake_case__    =					"abc1abc12"
    snake_case__    =					"alskfjaldsabc1abc1abc12k23adsfabcabc"
    snake_case__    =					"alskfjaldsk23adsfabcabc"
    assert rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				) and not rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				)

    # Test 2)
    snake_case__    =					"ABABX"
    snake_case__    =					"ABABZABABYABABX"
    assert rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				)

    # Test 3)
    snake_case__    =					"AAAB"
    snake_case__    =					"ABAAAAAB"
    assert rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				)

    # Test 4)
    snake_case__    =					"abcdabcy"
    snake_case__    =					"abcxabcdabxabcdabcdabcy"
    assert rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				)

    # Test 5)
    snake_case__    =					"Lü"
    snake_case__    =					"Lüsai"
    assert rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				)
    snake_case__    =					"Lue"
    assert not rabin_karp(__lowerCAmelCase     ,		__lowerCAmelCase				)
    print("Success."				)


if __name__ == "__main__":
     test_rabin_karp()





import math





def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase     ,		__lowerCAmelCase				):

    if initial_intensity < 0:
        raise ValueError("The value of intensity cannot be negative"				)
        # handling of negative values of initial intensity
    if angle < 0 or angle > 360:
        raise ValueError("In Malus Law, the angle is in the range 0-360 degrees"				)
        # handling of values out of allowed range
    return initial_intensity * (math.cos(math.radians(__lowerCAmelCase				)				) ** 2)


if __name__ == "__main__":
     import doctest

     doctest.testmod(name='''malus_law''')



