



'''simple docstring'''






import random
import sys

from . import cryptomath_module as cryptomath

A_				:					Optional[Any]							=      (
    r""" !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"""
    r"""abcdefghijklmnopqrstuvwxyz{|}~"""
)




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_			,  lowerCAmelCase_						)->						None:





       '''simple docstring'''


       if mode == "encrypt":
              if key_a == 1:
                     sys.exit(
                         """The affine cipher becomes weak when key """
                         """A is set to 1. Choose different key"""						)
              if key_b == 0:
                     sys.exit(
                         """The affine cipher becomes weak when key """
                         """B is set to 0. Choose different key"""						)
       if key_a < 0 or key_b < 0 or key_b > len(lowerCAmelCase_						) - 1:
              sys.exit(
                  """Key A must be greater than 0 and key B must """
                  F'''be between 0 and {len(lowerCAmelCase_						) - 1}.'''						)
       if cryptomath.gcd(lowerCAmelCase_			,  len(lowerCAmelCase_						)						) != 1:
              sys.exit(
                  F'''Key A {key_a} and the symbol set size {len(lowerCAmelCase_						)} '''
                  """are not relatively prime. Choose a different key."""						)




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_						)->						str:





       '''simple docstring'''


       _UpperCAmelCase	,_UpperCAmelCase    :		Union[str, Any]     	=					divmod(lowerCAmelCase_			,  len(lowerCAmelCase_						)						)
       check_keys(lowerCAmelCase_			,  lowerCAmelCase_			,  """encrypt"""						)
       _UpperCAmelCase    :		Any     	=					""""""
       for symbol in message:
              if symbol in SYMBOLS:
                     _UpperCAmelCase    :		Optional[Any]     	=					SYMBOLS.find(lowerCAmelCase_						)
                     cipher_text += SYMBOLS[(sym_index * key_a + key_b) % len(lowerCAmelCase_						)]
              else:
                     cipher_text += symbol
       return cipher_text




def        snake_case_   (	lowerCAmelCase_			,  lowerCAmelCase_						)->						str:





       '''simple docstring'''


       _UpperCAmelCase	,_UpperCAmelCase    :		Dict     	=					divmod(lowerCAmelCase_			,  len(lowerCAmelCase_						)						)
       check_keys(lowerCAmelCase_			,  lowerCAmelCase_			,  """decrypt"""						)
       _UpperCAmelCase    :		Tuple     	=					""""""
       _UpperCAmelCase    :		Dict     	=					cryptomath.find_mod_inverse(lowerCAmelCase_			,  len(lowerCAmelCase_						)						)
       for symbol in message:
              if symbol in SYMBOLS:
                     _UpperCAmelCase    :		int     	=					SYMBOLS.find(lowerCAmelCase_						)
                     plain_text += SYMBOLS[
                         (sym_index - key_b) * mod_inverse_of_key_a % len(lowerCAmelCase_						)
                     ]
              else:
                     plain_text += symbol
       return plain_text




def        snake_case_   (	)->						int:





       '''simple docstring'''


       while True:
              _UpperCAmelCase    :		Any     	=					random.randint(2			,  len(lowerCAmelCase_						)						)
              _UpperCAmelCase    :		int     	=					random.randint(2			,  len(lowerCAmelCase_						)						)
              if cryptomath.gcd(lowerCAmelCase_			,  len(lowerCAmelCase_						)						) == 1 and key_b % len(lowerCAmelCase_						) != 0:
                     return key_b * len(lowerCAmelCase_						) + key_b




def        snake_case_   (	)->						None:





       '''simple docstring'''


       _UpperCAmelCase    :		List[Any]     	=					input("""Enter message: """						).strip()
       _UpperCAmelCase    :		List[Any]     	=					int(input("""Enter key [2000 - 9000]: """						).strip()						)
       _UpperCAmelCase    :		Optional[Any]     	=					input("""Encrypt/Decrypt [E/D]: """						).strip().lower()

       if mode.startswith("""e"""						):
              _UpperCAmelCase    :		Union[str, Any]     	=					"""encrypt"""
              _UpperCAmelCase    :		Any     	=					encrypt_message(lowerCAmelCase_			,  lowerCAmelCase_						)
       elif mode.startswith("""d"""						):
              _UpperCAmelCase    :		Any     	=					"""decrypt"""
              _UpperCAmelCase    :		List[str]     	=					decrypt_message(lowerCAmelCase_			,  lowerCAmelCase_						)
       print(F'''\n{mode.title()}ed text: \n{translated}'''						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   # main()










"""simple docstring"""






def    __lowerCamelCase     (							SCREAMING_SNAKE_CASE				)		->							Dict:






       """simple docstring"""




       _UpperCAmelCase			     =  [701, 301, 132, 57, 23, 10, 4, 1]
       for gap in gaps:
              for i in range(SCREAMING_SNAKE_CASE,len(SCREAMING_SNAKE_CASE				)				):
                     _UpperCAmelCase			     =  collection[i]
                     _UpperCAmelCase			     =  i
                     while j >= gap and collection[j - gap] > insert_value:
                            _UpperCAmelCase			     =  collection[j - gap]
                            j -= gap
                     if j != i:
                            _UpperCAmelCase			     =  insert_value
       return collection


if __name__ == "__main__":
    from doctest import testmod

    testmod()
    lowerCAmelCase_      =				input('''Enter numbers separated by a comma:\n''').strip()
    lowerCAmelCase_      =				[int(item) for item in user_input.split(''',''')]
    print(shell_sort(unsorted))






