

import qiskit
from qiskit.providers import Backend





def  _snake_case		(snake_case_					:     Dict    ,       snake_case_					:     Any  )							->		tuple[qiskit.QuantumCircuit, str, str]:
  __UpperCAmelCase,			__UpperCAmelCase	:  int		=     bin(_UpperCAmelCase  )[2:], bin(_UpperCAmelCase  )[2:]  # Remove leading '0b'

  # Ensure that both strings are of the same length
  if len(_UpperCAmelCase  ) > len(_UpperCAmelCase  ):
    __UpperCAmelCase	:  Tuple		=     y.zfill(len(_UpperCAmelCase  )  )
  else:
    __UpperCAmelCase	:  Tuple		=     x.zfill(len(_UpperCAmelCase  )  )

  # We need (3 * number of bits in the larger number)+1 qBits
  # The second parameter is the number of classical registers, to measure the result
  __UpperCAmelCase	:  Tuple		=     qiskit.QuantumCircuit((len(_UpperCAmelCase  ) * 3) + 1    ,       len(_UpperCAmelCase  ) + 1  )

  # We are essentially "not-ing" the bits that are 1
  # Reversed because it's easier to perform ops on more significant bits
  for i in range(len(_UpperCAmelCase  )  ):
    if x[::-1][i] == "1":
      circuit.x(_UpperCAmelCase  )
  for j in range(len(_UpperCAmelCase  )  ):
    if y[::-1][j] == "1":
      circuit.x(len(_UpperCAmelCase  ) + j  )

  return circuit, x, y





def  _snake_case		(snake_case_					:     Any    ,       snake_case_					:     Dict    ,       snake_case_					:     Union[str, Any]    ,       snake_case_					:     Optional[Any]    ,       snake_case_					:     str    ,       )							->		int:
  circuit.ccx(_UpperCAmelCase    ,       _UpperCAmelCase    ,       _UpperCAmelCase  )
  circuit.cx(_UpperCAmelCase    ,       _UpperCAmelCase  )
  circuit.ccx(_UpperCAmelCase    ,       _UpperCAmelCase    ,       _UpperCAmelCase  )
  circuit.cx(_UpperCAmelCase    ,       _UpperCAmelCase  )
  circuit.cx(_UpperCAmelCase    ,       _UpperCAmelCase  )





def  _snake_case		(snake_case_					:     int    ,       snake_case_					:     Optional[int]    ,       snake_case_					:     Union[str, Any] = qiskit.Aer.get_backend('aer_simulator'  )    ,       )							->		int:






  if vala < 0 or vala < 0:
    raise ValueError('Both Integers must be positive!'  )

  # Store the Integers
  __UpperCAmelCase,			__UpperCAmelCase,			__UpperCAmelCase	:  Optional[Any]		=     store_two_classics(_UpperCAmelCase    ,       _UpperCAmelCase  )
  for i in range(len(_UpperCAmelCase  )  ):
    full_adder(_UpperCAmelCase    ,       _UpperCAmelCase    ,       len(_UpperCAmelCase  ) + i    ,       len(_UpperCAmelCase  ) + len(_UpperCAmelCase  ) + i    ,       len(_UpperCAmelCase  ) + len(_UpperCAmelCase  ) + i + 1  )
    circuit.barrier()  # Optional, just for aesthetics

  # Measure the resultant qBits
  for i in range(len(_UpperCAmelCase  ) + 1  ):
    circuit.measure([(len(_UpperCAmelCase  ) * 2) + i]    ,       [i]  )

  __UpperCAmelCase	:  Optional[Any]		=     qiskit.execute(_UpperCAmelCase    ,       _UpperCAmelCase    ,       shots=1  ).result()

  # The result is in binary. Convert it back to int
  return int(list(res.get_counts()  )[0]    ,       2  )


if __name__ == "__main__":
      import doctest

      doctest.testmod()












"""simple docstring"""


a__       :  Optional[Any]       		=					{
    """A""": ("""ABCDEFGHIJKLM""", """NOPQRSTUVWXYZ"""),
    """B""": ("""ABCDEFGHIJKLM""", """NOPQRSTUVWXYZ"""),
    """C""": ("""ABCDEFGHIJKLM""", """ZNOPQRSTUVWXY"""),
    """D""": ("""ABCDEFGHIJKLM""", """ZNOPQRSTUVWXY"""),
    """E""": ("""ABCDEFGHIJKLM""", """YZNOPQRSTUVWX"""),
    """F""": ("""ABCDEFGHIJKLM""", """YZNOPQRSTUVWX"""),
    """G""": ("""ABCDEFGHIJKLM""", """XYZNOPQRSTUVW"""),
    """H""": ("""ABCDEFGHIJKLM""", """XYZNOPQRSTUVW"""),
    """I""": ("""ABCDEFGHIJKLM""", """WXYZNOPQRSTUV"""),
    """J""": ("""ABCDEFGHIJKLM""", """WXYZNOPQRSTUV"""),
    """K""": ("""ABCDEFGHIJKLM""", """VWXYZNOPQRSTU"""),
    """L""": ("""ABCDEFGHIJKLM""", """VWXYZNOPQRSTU"""),
    """M""": ("""ABCDEFGHIJKLM""", """UVWXYZNOPQRST"""),
    """N""": ("""ABCDEFGHIJKLM""", """UVWXYZNOPQRST"""),
    """O""": ("""ABCDEFGHIJKLM""", """TUVWXYZNOPQRS"""),
    """P""": ("""ABCDEFGHIJKLM""", """TUVWXYZNOPQRS"""),
    """Q""": ("""ABCDEFGHIJKLM""", """STUVWXYZNOPQR"""),
    """R""": ("""ABCDEFGHIJKLM""", """STUVWXYZNOPQR"""),
    """S""": ("""ABCDEFGHIJKLM""", """RSTUVWXYZNOPQ"""),
    """T""": ("""ABCDEFGHIJKLM""", """RSTUVWXYZNOPQ"""),
    """U""": ("""ABCDEFGHIJKLM""", """QRSTUVWXYZNOP"""),
    """V""": ("""ABCDEFGHIJKLM""", """QRSTUVWXYZNOP"""),
    """W""": ("""ABCDEFGHIJKLM""", """PQRSTUVWXYZNO"""),
    """X""": ("""ABCDEFGHIJKLM""", """PQRSTUVWXYZNO"""),
    """Y""": ("""ABCDEFGHIJKLM""", """OPQRSTUVWXYZN"""),
    """Z""": ("""ABCDEFGHIJKLM""", """OPQRSTUVWXYZN"""),
}





def 				a__      (	_UpperCAmelCase						)     ->	list[tuple[str, str]]:

 '''simple docstring'''






 return [alphabet[char] for char in key.upper()]





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						)     ->	str:

 '''simple docstring'''






 snake_case__     				=					""
 snake_case__     				=					0
 snake_case__     				=					generate_table(_UpperCAmelCase						)
 for char in words.upper():
  cipher += get_opponent(table[count]						,  _UpperCAmelCase						)
  snake_case__     				=					(count + 1) % len(_UpperCAmelCase						)
 return cipher





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						)     ->	str:

 '''simple docstring'''






 return encrypt(_UpperCAmelCase						,  _UpperCAmelCase						)





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						)     ->	tuple[int, int]:

 '''simple docstring'''






 snake_case__     				=					0 if char in table[0] else 1
 snake_case__     				=					table[row].index(_UpperCAmelCase						)
 return row, col





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						)     ->	str:

 '''simple docstring'''






 snake_case__				, snake_case__     				=					get_position(_UpperCAmelCase						,  char.upper()						)
 if row == 1:
  return table[0][col]
 else:
  return table[1][col] if row == 0 else char


if __name__ == "__main__":
   import doctest

   doctest.testmod()  # Fist ensure that all our tests are passing...
   a__       :  int       		=					input("""Enter key: """).strip()
   a__       :  Optional[int]       		=					input("""Enter text to encrypt: """).strip()
   a__       :  Dict       		=					encrypt(key, text)

   print(f'''Encrypted: {cipher_text}''')
   print(f'''Decrypted with key: {decrypt(key, cipher_text)}''')

