



'''simple docstring'''






import string

import numpy
def    lowerCamelCase__ (		_A				,    _A       ):
  return b if a == 0 else greatest_common_divisor(b % a				,    _lowerCAmelCase       )




class 							a__:
    lowercase__				=					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)
    lowercase__				=					numpy.vectorize(lambda lowerCamelCase__			: x % 36			)

    lowercase__				=					numpy.vectorize(__UpperCAmelCase			)







    def __init__(   self				:						Tuple		,    __snake_case				:						numpy.ndarray			):
      a		:      int       =  self.modulus(_lowerCamelCase			)  # mod36 calc's on the encrypt key
      self.check_determinant()  # validate the determinant of the encryption key
      a		:      Dict       =  encrypt_key.shape[0]







    def     lowercase_ (   self				:						Optional[Any]		,    __snake_case				:						str			):
      return self.key_string.index(_lowerCamelCase			)







    def     lowercase_ (   self				:						List[str]		,    __snake_case				:						int			):
      return self.key_string[round(_lowerCamelCase			)]







    def     lowercase_ (   self				:						List[str]			):
      a		:      int       =  round(numpy.linalg.det(self.encrypt_key			)			)

      if det < 0:
        a		:      List[str]       =  det % len(self.key_string			)

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







    def     lowercase_ (   self				:						Dict		,    __snake_case				:						str			):
      a		:      int       =  [char for char in text.upper() if char in self.key_string]

      a		:      int       =  chars[-1]
      while len(_lowerCamelCase			) % self.break_key != 0:
        chars.append(_lowerCamelCase			)

      return "".join(_lowerCamelCase			)







    def     lowercase_ (   self				:						Optional[int]		,    __snake_case				:						str			):
      a		:      List[Any]       =  self.process_text(text.upper()			)
      a		:      Union[str, Any]       =  ''

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

      return encrypted







    def     lowercase_ (   self				:						str			):
      a		:      Any       =  round(numpy.linalg.det(self.encrypt_key			)			)

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

      a		:      Union[str, Any]       =  (
          det_inv
          * numpy.linalg.det(self.encrypt_key			)
          * numpy.linalg.inv(self.encrypt_key			)
      )

      return self.to_int(self.modulus(_lowerCamelCase			)			)







    def     lowercase_ (   self				:						Union[str, Any]		,    __snake_case				:						str			):
      a		:      Any       =  self.make_decrypt_key()
      a		:      str       =  self.process_text(text.upper()			)
      a		:      List[str]       =  ''

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

      return decrypted
def    lowerCamelCase__ (		):
  a		:      Union[str, Any]       =  int(input('Enter the order of the encryption key: '       )       )
  a		:      Optional[int]       =  []

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

  a		:      Optional[int]       =  HillCipher(numpy.array(_lowerCAmelCase       )       )

  print('Would you like to encrypt or decrypt some text? (1 or 2)'       )
  a		:      List[Any]       =  input('\n1. Encrypt\n2. Decrypt\n'       )
  if option == "1":
    a		:      Union[str, Any]       =  input('What text would you like to encrypt?: '       )
    print('Your encrypted text is:'       )
    print(hc.encrypt(_lowerCAmelCase       )       )
  elif option == "2":
    a		:      Any       =  input('What text would you like to decrypt?: '       )
    print('Your decrypted text is:'       )
    print(hc.decrypt(_lowerCAmelCase       )       )


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     main()




'''simple docstring'''






from pathlib import Path

import fire
def    lowerCamelCase__ (		_A				,    _A				,    _A       ):
  a		:      Optional[Any]       =  Path(_A       )
  a		:      Tuple       =  Path(_A       )
  dest_dir.mkdir(exist_ok=_A       )
  for path in src_dir.iterdir():
    a		:      Tuple       =  [x.rstrip() for x in list(path.open().readlines()       )][:n]
    a		:      List[str]       =  dest_dir.joinpath(path.name       )
    print(_A       )
    dest_path.open('w'       ).write('\n'.join(_A       )       )


if __name__ == "__main__":
     fire.Fire(minify)