



'''simple docstring'''





from __future__ import annotations
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase							,   UpperCamelCase      ):



				"""simple docstring"""





				lowerCAmelCase__			:  Any											= get_failure_array(UpperCamelCase      )

				# 2) Step through text searching for pattern
				lowerCAmelCase__			:  List[Any]											= 0, 0  # index into text, pattern
				while i < len(UpperCamelCase      ):
								if pattern[j] == text[i]:
												if j == (len(UpperCamelCase      ) - 1):
																return True
												j += 1

								# if this is a prefix in our pattern
								# just go back far enough to continue
								elif j > 0:
												lowerCAmelCase__			:  Union[str, Any]											= failure[j - 1]
												continue
								i += 1
				return False
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase      ):



				"""simple docstring"""





				lowerCAmelCase__			:  Tuple											= [0]
				lowerCAmelCase__			:  Optional[int]											= 0
				lowerCAmelCase__			:  Optional[Any]											= 1
				while j < len(UpperCamelCase      ):
								if pattern[i] == pattern[j]:
												i += 1
								elif i > 0:
												lowerCAmelCase__			:  List[Any]											= failure[i - 1]
												continue
								j += 1
								failure.append(UpperCamelCase      )
				return failure


if __name__ == "__main__":
	# Test 1)
	_lowerCAmelCase										=     '''abc1abc12'''
	_lowerCAmelCase										=     '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
	_lowerCAmelCase										=     '''alskfjaldsk23adsfabcabc'''
	assert kmp(pattern, texta) and not kmp(pattern, texta)

	# Test 2)
	_lowerCAmelCase										=     '''ABABX'''
	_lowerCAmelCase										=     '''ABABZABABYABABX'''
	assert kmp(pattern, text)

	# Test 3)
	_lowerCAmelCase										=     '''AAAB'''
	_lowerCAmelCase										=     '''ABAAAAAB'''
	assert kmp(pattern, text)

	# Test 4)
	_lowerCAmelCase										=     '''abcdabcy'''
	_lowerCAmelCase										=     '''abcxabcdabxabcdabcdabcy'''
	assert kmp(pattern, text)

	# Test 5)
	_lowerCAmelCase										=     '''aabaabaaa'''
	assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]







'''simple docstring'''





_lowerCAmelCase										=     '''Input must be a string of 8 numbers plus letter'''
_lowerCAmelCase										=     '''TRWAGMYFPDXBNJZSQVHLCKE'''
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase      ):



    """simple docstring"""





    if not isinstance(UpperCamelCase							,   UpperCamelCase      ):
        lowerCAmelCase__			:  List[Any]											= f"""Expected string as input, found {type(UpperCamelCase      ).__name__}"""
        raise TypeError(UpperCamelCase      )

    lowerCAmelCase__			:  Union[str, Any]											= spanish_id.replace("""-"""							,   """"""      ).upper()
    if len(UpperCamelCase      ) != 9:
        raise ValueError(UpperCamelCase      )

    try:
        lowerCAmelCase__			:  Optional[int]											= int(spanish_id_clean[0:8]      )
        lowerCAmelCase__			:  int											= spanish_id_clean[8]
    except ValueError as ex:
        raise ValueError(UpperCamelCase      ) from ex

    if letter.isdigit():
        raise ValueError(UpperCamelCase      )

    return letter == LOOKUP_LETTERS[number % 23]


if __name__ == "__main__":
 import doctest

 doctest.testmod()


