




import math

import qiskit







def lowerCamelCase__  (     _lowercase = 1					,		_lowercase = 1					,		_lowercase = 1 ):

     '''simple docstring'''


     if (
         isinstance(_lowercase					,		_lowercase )
         or isinstance(_lowercase					,		_lowercase )
         or isinstance(_lowercase					,		_lowercase )
     ):
          raise TypeError('''inputs must be integers.''' )

     if (input_a < 0) or (input_a < 0) or (carry_in < 0):
          raise ValueError('''inputs must be positive.''' )

     if (
         (math.floor(_lowercase ) != input_a)
         or (math.floor(_lowercase ) != input_a)
         or (math.floor(_lowercase ) != carry_in)
     ):
          raise ValueError('''inputs must be exact integers.''' )

     if (input_a > 2) or (input_a > 2) or (carry_in > 2):
          raise ValueError('''inputs must be less or equal to 2.''' )

     # build registers
     UpperCAmelCase_     :				List[str]  =     qiskit.QuantumRegister(4					,		'''qr''' )
     UpperCAmelCase_     :				Tuple  =     qiskit.ClassicalRegister(2					,		'''cr''' )
     # list the entries
     UpperCAmelCase_     :				str  =     [input_a, input_a, carry_in]

     UpperCAmelCase_     :				str  =     qiskit.QuantumCircuit(_lowercase					,		_lowercase )

     for i in range(0					,		3 ):
          if entry[i] == 2:
               quantum_circuit.h(_lowercase )  # for hadamard entries
          elif entry[i] == 1:
               quantum_circuit.x(_lowercase )  # for 1 entries
          elif entry[i] == 0:
               quantum_circuit.i(_lowercase )  # for 0 entries

    # build the circuit
     quantum_circuit.ccx(0					,		1					,		3 )  # ccx = toffoli gate
     quantum_circuit.cx(0					,		1 )
     quantum_circuit.ccx(1					,		2					,		3 )
     quantum_circuit.cx(1					,		2 )
     quantum_circuit.cx(0					,		1 )

     quantum_circuit.measure([2, 3]					,		_lowercase )  # measure the last two qbits

     UpperCAmelCase_     :				Union[str, Any]  =     qiskit.Aer.get_backend('''aer_simulator''' )
     UpperCAmelCase_     :				str  =     qiskit.execute(_lowercase					,		_lowercase					,		shots=1000 )

     return job.result().get_counts(_lowercase )


if __name__ == "__main__":
     print(F"""Total sum count for state is: {quantum_full_adder(1, 1, 1)}""")






'''simple docstring'''




a__					:			Optional[Any]          =     '''Alexander Joslin'''

import operator as op

from .stack import Stack




def 						__lowerCamelCase			(	UpperCAmelCase_							)   ->int:
	snake_case__	       =   {'*': op.mul, '/': op.truediv, '+': op.add, '-': op.sub}

	snake_case__	       =   Stack()
	snake_case__	       =   Stack()

	for i in equation:
		if i.isdigit():
			# RULE 1
			operand_stack.push(int(UpperCAmelCase_							)							)
		elif i in operators:
			# RULE 2
			operator_stack.push(UpperCAmelCase_							)
		elif i == ")":
			# RULE 4
			snake_case__	       =   operator_stack.peek()
			operator_stack.pop()
			snake_case__	       =   operand_stack.peek()
			operand_stack.pop()
			snake_case__	       =   operand_stack.peek()
			operand_stack.pop()

			snake_case__	       =   operators[opr](UpperCAmelCase_					,				UpperCAmelCase_							)
			operand_stack.push(UpperCAmelCase_							)

    # RULE 5
	return operand_stack.peek()


if __name__ == "__main__":
			a__					:			Any          =     '''(5 + ((4 * 2) * (2 + 3)))'''
			# answer = 45
			print(f"""{equation} = {dijkstras_two_stack_algorithm(equation)}""")



