





import qiskit
from qiskit.providers import Backend
def  __UpperCamelCase    (						snake_case							,			snake_case      )    ->		tuple[qiskit.QuantumCircuit, str, str]:


   '''simple docstring'''







   __A   ,		__A    =  bin(snake_case      )[2:], bin(snake_case      )[2:]  # Remove leading '0b'

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

   # 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
   __A    =  qiskit.QuantumCircuit((len(snake_case      ) * 3) + 1							,			len(snake_case      ) + 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(snake_case      )      ):
      if x[::-1][i] == "1":
         circuit.x(snake_case      )
   for j in range(len(snake_case      )      ):
      if y[::-1][j] == "1":
         circuit.x(len(snake_case      ) + j      )

   return circuit, x, y
def  __UpperCamelCase    (						snake_case							,			snake_case							,			snake_case							,			snake_case							,			snake_case							,			)    ->		List[str]:


   '''simple docstring'''







   circuit.ccx(snake_case							,			snake_case							,			snake_case      )
   circuit.cx(snake_case							,			snake_case      )
   circuit.ccx(snake_case							,			snake_case							,			snake_case      )
   circuit.cx(snake_case							,			snake_case      )
   circuit.cx(snake_case							,			snake_case      )
def  __UpperCamelCase    (						snake_case							,			snake_case							,			snake_case = qiskit.Aer.get_backend('''aer_simulator'''      )							,			)    ->		int:


   '''simple docstring'''







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

   # Store the Integers
   __A   ,		__A   ,		__A    =  store_two_classics(snake_case							,			snake_case      )
   for i in range(len(snake_case      )      ):
      full_adder(snake_case							,			snake_case							,			len(snake_case      ) + i							,			len(snake_case      ) + len(snake_case      ) + i							,			len(snake_case      ) + len(snake_case      ) + i + 1      )
      circuit.barrier()  # Optional, just for aesthetics

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

   __A    =  qiskit.execute(snake_case							,			snake_case							,			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()








from __future__ import annotations
def  __UpperCamelCase    (						snake_case      )    ->		bool:


   '''simple docstring'''







   __A    =  42
   __A    =  list(snake_case      )
   __A   ,		__A    =  _vector[:-1], int(_vector[-1]      )
   __A    =  [int(snake_case      ) for digit in __vector]

   vector.reverse()
   for i, digit in enumerate(snake_case      ):
      if i & 1 == 0:
         __A    =  digit * 2
         if doubled > 9:
            doubled -= 9
         check_digit += doubled
      else:
         check_digit += digit

   return check_digit % 1_0 == 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    assert is_luhn("""79927398713""")
    assert not is_luhn("""79927398714""")

