

"""simple docstring"""




import numpy as np
from numpy import floataa
from numpy.typing import NDArray







def       snake_case__    (       lowerCAmelCase_,   lowerCAmelCase_      ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE						,  SCREAMING_SNAKE_CASE										=np.shape(lowerCAmelCase_      )

     SCREAMING_SNAKE_CASE										=np.zeros((rows, 1),   dtype=lowerCAmelCase_      )
     for row in reversed(range(lowerCAmelCase_      )      ):
          SCREAMING_SNAKE_CASE										=0
          for col in range(row + 1,   lowerCAmelCase_      ):
               total += coefficients[row, col] * x[col]

          SCREAMING_SNAKE_CASE										=(vector[row] - total) / coefficients[row, row]

     return x







def       snake_case__    (       lowerCAmelCase_,   lowerCAmelCase_      ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE						,  SCREAMING_SNAKE_CASE										=np.shape(lowerCAmelCase_      )
     if rows != columns:
          return np.array((),   dtype=lowerCAmelCase_      )

     # augmented matrix
     SCREAMING_SNAKE_CASE										=np.concatenate((coefficients, vector),   axis=1      )
     SCREAMING_SNAKE_CASE										=augmented_mat.astype('float64'      )

     # scale the matrix leaving it triangular
     for row in range(rows - 1      ):
          SCREAMING_SNAKE_CASE										=augmented_mat[row, row]
          for col in range(row + 1,   lowerCAmelCase_      ):
               SCREAMING_SNAKE_CASE										=augmented_mat[col, row] / pivot
               augmented_mat[col, :] -= factor * augmented_mat[row, :]

     SCREAMING_SNAKE_CASE										=retroactive_resolution(
         augmented_mat[:, 0:columns],   augmented_mat[:, columns : columns + 1]      )

     return x


if __name__ == "__main__":
 import doctest

 doctest.testmod()




import random
import sys

_lowerCamelCase								="ABCDEFGHIJKLMNOPQRSTUVWXYZ"







def       snake_case__    (       ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE										=input('Enter message: '      )
     SCREAMING_SNAKE_CASE										='LFWOAYUISVKMNXPBDCRJTQEGHZ'
     SCREAMING_SNAKE_CASE										=input('Encrypt/Decrypt [e/d]: '      )

     check_valid_key(lowerCAmelCase_      )

     if resp.lower().startswith('e'      ):
          SCREAMING_SNAKE_CASE										='encrypt'
          SCREAMING_SNAKE_CASE										=encrypt_message(lowerCAmelCase_,   lowerCAmelCase_      )
     elif resp.lower().startswith('d'      ):
          SCREAMING_SNAKE_CASE										='decrypt'
          SCREAMING_SNAKE_CASE										=decrypt_message(lowerCAmelCase_,   lowerCAmelCase_      )

     print(F'\n{mode.title()}ion: \n{translated}'      )







def       snake_case__    (       lowerCAmelCase_      ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE										=list(lowerCAmelCase_      )
     SCREAMING_SNAKE_CASE										=list(lowerCAmelCase_      )
     key_list.sort()
     letters_list.sort()

     if key_list != letters_list:
          sys.exit('Error in the key or symbol set.'      )







def       snake_case__    (       lowerCAmelCase_,   lowerCAmelCase_      ):





     """simple docstring"""







     return translate_message(lowerCAmelCase_,   lowerCAmelCase_,   'encrypt'      )







def       snake_case__    (       lowerCAmelCase_,   lowerCAmelCase_      ):





     """simple docstring"""







     return translate_message(lowerCAmelCase_,   lowerCAmelCase_,   'decrypt'      )







def       snake_case__    (       lowerCAmelCase_,   lowerCAmelCase_,   lowerCAmelCase_      ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE										=''
     SCREAMING_SNAKE_CASE										=LETTERS
     SCREAMING_SNAKE_CASE										=key

     if mode == "decrypt":
          SCREAMING_SNAKE_CASE						,  SCREAMING_SNAKE_CASE										=chars_b, chars_a

     for symbol in message:
          if symbol.upper() in chars_a:
               SCREAMING_SNAKE_CASE										=chars_a.find(symbol.upper()      )
               if symbol.isupper():
                    translated += chars_b[sym_index].upper()
               else:
                    translated += chars_b[sym_index].lower()
          else:
               translated += symbol

     return translated







def       snake_case__    (       ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE										=list(lowerCAmelCase_      )
     random.shuffle(lowerCAmelCase_      )
     return "".join(lowerCAmelCase_      )


if __name__ == "__main__":
 main()

