




'''simple docstring'''


import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute
def 	snake_case_					(UpperCamelCase :						int = 3   ):





							'''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).'''   )

							_a			  =       QuantumRegister(UpperCamelCase				,		'''qr'''   )
							_a			  =       ClassicalRegister(UpperCamelCase				,		'''cr'''   )

							_a			  =       QuantumCircuit(UpperCamelCase				,		UpperCamelCase   )

							_a			  =       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
							_a			  =       Aer.get_backend('''qasm_simulator'''   )
							_a			  =       execute(UpperCamelCase				,		UpperCamelCase				,		shots=1_0000   )

							return job.result().get_counts(UpperCamelCase   )


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







'''simple docstring'''


import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
				import ctypes
				import msvcrt  # noqa

				class     A					(	ctypes.Structure					):
											# _fields is a specific attr expected by ctypes
											lowercase_           =       [('size', ctypes.c_int), ('visible', ctypes.c_byte)]
def 	snake_case_					():





							'''simple docstring'''


							if os.name == "nt":
														_a			  =       CursorInfo()
														_a			  =       ctypes.windll.kernelaa.GetStdHandle(-11   )
														ctypes.windll.kernelaa.GetConsoleCursorInfo(UpperCamelCase				,		ctypes.byref(UpperCamelCase   )   )
														_a			  =       False
														ctypes.windll.kernelaa.SetConsoleCursorInfo(UpperCamelCase				,		ctypes.byref(UpperCamelCase   )   )
							elif os.name == "posix":
														sys.stdout.write('''\033[?25l'''   )
														sys.stdout.flush()
def 	snake_case_					():





							'''simple docstring'''


							if os.name == "nt":
														_a			  =       CursorInfo()
														_a			  =       ctypes.windll.kernelaa.GetStdHandle(-11   )
														ctypes.windll.kernelaa.GetConsoleCursorInfo(UpperCamelCase				,		ctypes.byref(UpperCamelCase   )   )
														_a			  =       True
														ctypes.windll.kernelaa.SetConsoleCursorInfo(UpperCamelCase				,		ctypes.byref(UpperCamelCase   )   )
							elif os.name == "posix":
														sys.stdout.write('''\033[?25h'''   )
														sys.stdout.flush()

@contextmanager
def 	snake_case_					():





							'''simple docstring'''


							try:
														hide_cursor()
														yield
							finally:
														show_cursor()

