


'''simple docstring'''






import qiskit


def       _snake_case     (  A				,					A )		->					qiskit.result.counts.Counts:
							lowerCAmelCase__      =			qiskit.Aer.get_backend('''aer_simulator''' )

							lowerCAmelCase__      =			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
							lowerCAmelCase__      =			qiskit.execute(A				,					A				,					shots=1000 )

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


if __name__ == "__main__":
		__UpperCAmelCase					       =							half_adder(1, 1)
		print(f"""Half Adder Output Qubit Counts: {counts}""")



'''simple docstring'''






def       _snake_case     (  A )		->					bool:
							if not isinstance(A				,					A ):
														raise ValueError('''Input series is not valid, valid series - [2, 4, 6]''' )
							if len(A ) == 0:
														raise ValueError('''Input list must be a non empty list''' )
							if len(A ) == 1:
														return True
							lowerCAmelCase__      =			series[1] - series[0]
							for index in range(len(A ) - 1 ):
														if series[index + 1] - series[index] != common_diff:
																					return False
							return True


def       _snake_case     (  A )		->					float:
							if not isinstance(A				,					A ):
														raise ValueError('''Input series is not valid, valid series - [2, 4, 6]''' )
							if len(A ) == 0:
														raise ValueError('''Input list must be a non empty list''' )
							lowerCAmelCase__      =			0
							for val in series:
														answer += val
							return answer / len(A )


if __name__ == "__main__":
		import doctest

		doctest.testmod()