

'''simple docstring'''






import string

import numpy


def 	_A  (					A__  ,       A__   ):






	"""simple docstring"""



	return b if a == 0 else greatest_common_divisor(b % a  ,       A__   )






class     lowercase_			:




		"""simple docstring"""




		SCREAMING_SNAKE_CASE					:						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)
		SCREAMING_SNAKE_CASE					:						Dict           =    numpy.vectorize(lambda lowerCamelCase__   : x % 3_6   )

		SCREAMING_SNAKE_CASE					:						Optional[Any]           =    numpy.vectorize(lowerCamelCase__   )






		def __init__(   self     :  Any      ,lowercase__     :  numpy.ndarray    ):
			__lowercase													=				self.modulus(lowercase__    )  # mod36 calc's on the encrypt key
			self.check_determinant()  # validate the determinant of the encryption key
			__lowercase													=				encrypt_key.shape[0]






		def       SCREAMING_SNAKE_CASE   (   self     :  Dict      ,lowercase__     :  str    ):
			return self.key_string.index(lowercase__    )






		def       SCREAMING_SNAKE_CASE   (   self     :  Any      ,lowercase__     :  int    ):
			return self.key_string[round(lowercase__    )]






		def       SCREAMING_SNAKE_CASE   (   self     :  str    ):
			__lowercase													=				round(numpy.linalg.det(self.encrypt_key    )    )

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

			__lowercase													=				len(self.key_string    )
			if greatest_common_divisor(lowercase__      ,len(self.key_string    )    ) != 1:
				__lowercase													=				(
				    F"determinant modular {req_l} of encryption key({det}) "
				    F"is not co prime w.r.t {req_l}.\nTry another key."
				)
				raise ValueError(lowercase__    )






		def       SCREAMING_SNAKE_CASE   (   self     :  List[Any]      ,lowercase__     :  str    ):
			__lowercase													=				[char for char in text.upper() if char in self.key_string]

			__lowercase													=				chars[-1]
			while len(lowercase__    ) % self.break_key != 0:
				chars.append(lowercase__    )

			return "".join(lowercase__    )






		def       SCREAMING_SNAKE_CASE   (   self     :  Tuple      ,lowercase__     :  str    ):
			__lowercase													=				self.process_text(text.upper()    )
			__lowercase													=				''''''

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

			return encrypted






		def       SCREAMING_SNAKE_CASE   (   self     :  str    ):
			__lowercase													=				round(numpy.linalg.det(self.encrypt_key    )    )

			if det < 0:
				__lowercase													=				det % len(self.key_string    )
			__lowercase													=				None
			for i in range(len(self.key_string    )    ):
				if (det * i) % len(self.key_string    ) == 1:
					__lowercase													=				i
					break

			__lowercase													=				(
			    det_inv
			    * numpy.linalg.det(self.encrypt_key    )
			    * numpy.linalg.inv(self.encrypt_key    )
			)

			return self.to_int(self.modulus(lowercase__    )    )






		def       SCREAMING_SNAKE_CASE   (   self     :  str      ,lowercase__     :  str    ):
			__lowercase													=				self.make_decrypt_key()
			__lowercase													=				self.process_text(text.upper()    )
			__lowercase													=				''''''

			for i in range(0      ,len(lowercase__    ) - self.break_key + 1      ,self.break_key    ):
				__lowercase													=				text[i : i + self.break_key]
				__lowercase													=				[self.replace_letters(lowercase__    ) for char in batch]
				__lowercase													=				numpy.array([vec]    ).T
				__lowercase													=				self.modulus(decrypt_key.dot(lowercase__    )    ).T.tolist()[0]
				__lowercase													=				''''''.join(
				    self.replace_digits(lowercase__    ) for num in batch_decrypted    )
				decrypted += decrypted_batch

			return decrypted


def 	_A  (					):






	"""simple docstring"""



	__lowercase													=				int(input('''Enter the order of the encryption key: '''   )   )
	__lowercase													=				[]

	print('''Enter each row of the encryption key with space separated integers'''   )
	for _ in range(A__   ):
		__lowercase													=				[int(A__   ) for x in input().split()]
		hill_matrix.append(A__   )

	__lowercase													=				HillCipher(numpy.array(A__   )   )

	print('''Would you like to encrypt or decrypt some text? (1 or 2)'''   )
	__lowercase													=				input('''\n1. Encrypt\n2. Decrypt\n'''   )
	if option == "1":
		__lowercase													=				input('''What text would you like to encrypt?: '''   )
		print('''Your encrypted text is:'''   )
		print(hc.encrypt(A__   )   )
	elif option == "2":
		__lowercase													=				input('''What text would you like to decrypt?: '''   )
		print('''Your decrypted text is:'''   )
		print(hc.decrypt(A__   )   )


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	main()




'''simple docstring'''






def 	_A  (					A__ = 50   ):






 """simple docstring"""



 __lowercase													=				[1] * (length + 1)

 for row_length in range(3  ,       length + 1   ):
  for block_length in range(3  ,       row_length + 1   ):
   for block_start in range(row_length - block_length   ):
    ways_number[row_length] += ways_number[
        row_length - block_start - block_length - 1
    ]

   ways_number[row_length] += 1

 return ways_number[length]


if __name__ == "__main__":
 print(f'{solution() = }')

