



import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute





def 							A			(  _UpperCAmelCase       :     int = 3					)       ->				qiskit.result.counts.Counts:







			'''simple docstring'''
			if isinstance(_UpperCAmelCase							,     _UpperCAmelCase					):
						raise TypeError('number of qubits must be a integer.'					)
			if number_of_qubits <= 0:
						raise ValueError('number of qubits must be > 0.'					)
			if math.floor(_UpperCAmelCase					) != number_of_qubits:
						raise ValueError('number of qubits must be exact integer.'					)
			if number_of_qubits > 10:
						raise ValueError('number of qubits too large to simulate(>10).'					)

			_UpperCAmelCase	 =     QuantumRegister(_UpperCAmelCase							,     'qr'					)
			_UpperCAmelCase	 =     ClassicalRegister(_UpperCAmelCase							,     'cr'					)

			_UpperCAmelCase	 =     QuantumCircuit(_UpperCAmelCase							,     _UpperCAmelCase					)

			_UpperCAmelCase	 =     number_of_qubits

			for i in range(_UpperCAmelCase					):
						quantum_circuit.h(number_of_qubits - i - 1					)
						counter -= 1
						for j in range(_UpperCAmelCase					):
									quantum_circuit.cp(np.pi / 2 ** (counter - j)							,     _UpperCAmelCase							,     _UpperCAmelCase					)

			for k in range(number_of_qubits // 2					):
						quantum_circuit.swap(_UpperCAmelCase							,     number_of_qubits - k - 1					)

			# measure all the qubits
			quantum_circuit.measure(_UpperCAmelCase							,     _UpperCAmelCase					)
			# simulate with 10000 shots
			_UpperCAmelCase	 =     Aer.get_backend('qasm_simulator'					)
			_UpperCAmelCase	 =     execute(_UpperCAmelCase							,     _UpperCAmelCase							,     shots=10_000					)

			return job.result().get_counts(_UpperCAmelCase					)


if __name__ == "__main__":
							print(
							    f'''Total count for quantum fourier transform state is: \
    {quantum_fourier_transform(3)}'''
							)





def 							A			(  _UpperCAmelCase       :     int							,     _UpperCAmelCase       :     int					)       ->				str:







			'''simple docstring'''
			if a < 0 or b < 0:
						raise ValueError('the value of both inputs must be positive'					)

			_UpperCAmelCase	 =     str(bin(_UpperCAmelCase					)					)[2:]  # remove the leading "0b"
			_UpperCAmelCase	 =     str(bin(_UpperCAmelCase					)					)[2:]  # remove the leading "0b"

			_UpperCAmelCase	 =     max(len(_UpperCAmelCase					)							,     len(_UpperCAmelCase					)					)

			return "0b" + "".join(
			    str(int(char_a != char_b					)					)
			    for char_a, char_b in zip(a_binary.zfill(_UpperCAmelCase					)							,     b_binary.zfill(_UpperCAmelCase					)					)					)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
