




'''simple docstring'''


import math

import qiskit
def 						snake_case_       (UpperCamelCase			:    int = 1					,		UpperCamelCase			:    int = 1					,		UpperCamelCase			:    int = 1 ):





							'''simple docstring'''


							if (
							    isinstance(UpperCamelCase					,		UpperCamelCase )
							    or isinstance(UpperCamelCase					,		UpperCamelCase )
							    or isinstance(UpperCamelCase					,		UpperCamelCase )
							):
														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(UpperCamelCase ) != input_a)
							    or (math.floor(UpperCamelCase ) != input_a)
							    or (math.floor(UpperCamelCase ) != 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
							_a      	=							qiskit.QuantumRegister(4					,		'''qr''' )
							_a      	=							qiskit.ClassicalRegister(2					,		'''cr''' )
							# list the entries
							_a      	=							[input_a, input_a, carry_in]

							_a      	=							qiskit.QuantumCircuit(UpperCamelCase					,		UpperCamelCase )

							for i in range(0					,		3 ):
														if entry[i] == 2:
																					quantum_circuit.h(UpperCamelCase )  # for hadamard entries
														elif entry[i] == 1:
																					quantum_circuit.x(UpperCamelCase )  # for 1 entries
														elif entry[i] == 0:
																					quantum_circuit.i(UpperCamelCase )  # 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]					,		UpperCamelCase )  # measure the last two qbits

							_a      	=							qiskit.Aer.get_backend('''aer_simulator''' )
							_a      	=							qiskit.execute(UpperCamelCase					,		UpperCamelCase					,		shots=1000 )

							return job.result().get_counts(UpperCamelCase )


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







'''simple docstring'''


import qiskit
def 						snake_case_       (UpperCamelCase			:    int					,		UpperCamelCase			:    int ):





							'''simple docstring'''


							_a      	=							qiskit.Aer.get_backend('''aer_simulator''' )

							_a      	=							qiskit.QuantumCircuit(4					,		2 )
							# encode inputs in qubits 0 and 1
							if bita == 1:
														qc_ha.x(0 )
							if bita == 1:
														qc_ha.x(1 )
							qc_ha.barrier()

							# use cnots to write XOR of the inputs on qubit2
							qc_ha.cx(0					,		2 )
							qc_ha.cx(1					,		2 )

							# use ccx / toffoli gate to write AND of the inputs on qubit3
							qc_ha.ccx(0					,		1					,		3 )
							qc_ha.barrier()

							# extract outputs
							qc_ha.measure(2					,		0 )  # extract XOR value
							qc_ha.measure(3					,		1 )  # extract AND value

							# Execute the circuit on the qasm simulator
							_a      	=							qiskit.execute(UpperCamelCase					,		UpperCamelCase					,		shots=1000 )

							# Return the histogram data of the results of the experiment
							return job.result().get_counts(UpperCamelCase )


if __name__ == "__main__":
				_snake_case : Tuple  				=						half_adder(1, 1)
				print(F'''Half Adder Output Qubit Counts: {counts}''')

