



"""simple docstring"""
import string

import numpy
def    A_  (			_lowercase,					_lowercase	):







						'''simple docstring'''


						return b if a == 0 else greatest_common_divisor(b % a,					_lowercase	)
class 				lowerCamelCase  :






					'''simple docstring'''





					_A		:			int						=     string.ascii_uppercase + string.digits
					# This cipher takes alphanumerics into account
					# i.e. a total of 36 characters

					# take x and return x % len(key_string)
					_A		:			Union[str, Any]						=     numpy.vectorize(lambda _lowerCAmelCase				: x % 3_6				)

					_A		:			List[Any]						=     numpy.vectorize(_lowerCAmelCase				)






					def __init__(       self:							Optional[int]						,     snake_case:							numpy.ndarray						)   ->	None:
											snake_case_ :Optional[int]						=			self.modulus(snake_case						)  # mod36 calc's on the encrypt key
											self.check_determinant()  # validate the determinant of the encryption key
											snake_case_ :Union[str, Any]						=			encrypt_key.shape[0]






					def    lowerCAmelCase_				(       self:							Tuple						,     snake_case:							str						)   ->	int:
											return self.key_string.index(snake_case						)






					def    lowerCAmelCase_				(       self:							Tuple						,     snake_case:							int						)   ->	str:
											return self.key_string[round(snake_case						)]






					def    lowerCAmelCase_				(       self:							int						)   ->	None:
											snake_case_ :Optional[Any]						=			round(numpy.linalg.det(self.encrypt_key						)						)

											if det < 0:
																	snake_case_ :Any						=			det % len(self.key_string						)

											snake_case_ :Union[str, Any]						=			len(self.key_string						)
											if greatest_common_divisor(snake_case						,     len(self.key_string						)						) != 1:
																	snake_case_ :str						=			(
																	    f"""determinant modular {req_l} of encryption key({det}) """
																	    f"""is not co prime w.r.t {req_l}.\nTry another key."""
																	)
																	raise ValueError(snake_case						)






					def    lowerCAmelCase_				(       self:							Optional[int]						,     snake_case:							str						)   ->	str:
											snake_case_ :Union[str, Any]						=			[char for char in text.upper() if char in self.key_string]

											snake_case_ :Union[str, Any]						=			chars[-1]
											while len(snake_case						) % self.break_key != 0:
																	chars.append(snake_case						)

											return "".join(snake_case						)






					def    lowerCAmelCase_				(       self:							Dict						,     snake_case:							str						)   ->	str:
											snake_case_ :List[str]						=			self.process_text(text.upper()						)
											snake_case_ :List[Any]						=			""""""

											for i in range(0						,     len(snake_case						) - self.break_key + 1						,     self.break_key						):
																	snake_case_ :int						=			text[i : i + self.break_key]
																	snake_case_ :int						=			[self.replace_letters(snake_case						) for char in batch]
																	snake_case_ :Optional[int]						=			numpy.array([vec]						).T
																	snake_case_ :Any						=			self.modulus(self.encrypt_key.dot(snake_case						)						).T.tolist()[
																	    0
																	]
																	snake_case_ :Optional[Any]						=			"""""".join(
																	    self.replace_digits(snake_case						) for num in batch_encrypted						)
																	encrypted += encrypted_batch

											return encrypted






					def    lowerCAmelCase_				(       self:							Union[str, Any]						)   ->	numpy.ndarray:
											snake_case_ :Dict						=			round(numpy.linalg.det(self.encrypt_key						)						)

											if det < 0:
																	snake_case_ :List[Any]						=			det % len(self.key_string						)
											snake_case_ :Optional[int]						=			None
											for i in range(len(self.key_string						)						):
																	if (det * i) % len(self.key_string						) == 1:
																							snake_case_ :Dict						=			i
																							break

											snake_case_ :Optional[int]						=			(
											    det_inv
											    * numpy.linalg.det(self.encrypt_key						)
											    * numpy.linalg.inv(self.encrypt_key						)
											)

											return self.to_int(self.modulus(snake_case						)						)






					def    lowerCAmelCase_				(       self:							Optional[Any]						,     snake_case:							str						)   ->	str:
											snake_case_ :Dict						=			self.make_decrypt_key()
											snake_case_ :Tuple						=			self.process_text(text.upper()						)
											snake_case_ :Optional[int]						=			""""""

											for i in range(0						,     len(snake_case						) - self.break_key + 1						,     self.break_key						):
																	snake_case_ :Tuple						=			text[i : i + self.break_key]
																	snake_case_ :Dict						=			[self.replace_letters(snake_case						) for char in batch]
																	snake_case_ :List[str]						=			numpy.array([vec]						).T
																	snake_case_ :Optional[Any]						=			self.modulus(decrypt_key.dot(snake_case						)						).T.tolist()[0]
																	snake_case_ :int						=			"""""".join(
																	    self.replace_digits(snake_case						) for num in batch_decrypted						)
																	decrypted += decrypted_batch

											return decrypted

def    A_  (			):







						'''simple docstring'''


						snake_case_ :Dict						=			int(input("""Enter the order of the encryption key: """	)	)
						snake_case_ :Union[str, Any]						=			[]

						print("""Enter each row of the encryption key with space separated integers"""	)
						for _ in range(_lowercase	):
												snake_case_ :Union[str, Any]						=			[int(_lowercase	) for x in input().split()]
												hill_matrix.append(_lowercase	)

						snake_case_ :List[Any]						=			HillCipher(numpy.array(_lowercase	)	)

						print("""Would you like to encrypt or decrypt some text? (1 or 2)"""	)
						snake_case_ :int						=			input("""\n1. Encrypt\n2. Decrypt\n"""	)
						if option == "1":
												snake_case_ :Optional[Any]						=			input("""What text would you like to encrypt?: """	)
												print("""Your encrypted text is:"""	)
												print(hc.encrypt(_lowercase	)	)
						elif option == "2":
												snake_case_ :Dict						=			input("""What text would you like to decrypt?: """	)
												print("""Your decrypted text is:"""	)
												print(hc.decrypt(_lowercase	)	)


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						main()





"""simple docstring"""
import re
def    A_  (			_lowercase	):







						'''simple docstring'''


						snake_case_ :Optional[int]						=			re.compile(
						    r"""^(?:0|94|\+94|0{2}94)""" r"""7(0|1|2|4|5|6|7|8)""" r"""(-| |)""" r"""\d{7}$"""	)

						return bool(re.search(_lowercase,					_lowercase	)	)


if __name__ == "__main__":
						__a      =				"0094702343221"

						print(is_sri_lankan_phone_number(phone))
