

import math

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



def 				snake_case_(_UpperCamelCase = 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).'''					)

  _snake_case						=							QuantumRegister(_UpperCamelCase			,	'''qr'''					)
  _snake_case						=							ClassicalRegister(_UpperCamelCase			,	'''cr'''					)

  _snake_case						=							QuantumCircuit(_UpperCamelCase			,	_UpperCamelCase					)

  _snake_case						=							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
  _snake_case						=							Aer.get_backend('''qasm_simulator'''					)
  _snake_case						=							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)}'''
 )




import os
import sys
from contextlib import contextmanager


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



 class   lowercase_   (  ctypes.Structure					):
       # _fields is a specific attr expected by ctypes
       UpperCamelCase_      :		List[Any]										=    [("size", ctypes.c_int), ("visible", ctypes.c_byte)]



def 				snake_case_()							->     int:



  """simple docstring"""






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



def 				snake_case_()							->     Optional[Any]:



  """simple docstring"""






  if os.name == "nt":
    _snake_case						=							CursorInfo()
    _snake_case						=							ctypes.windll.kernelaa.GetStdHandle(-11					)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
    _snake_case						=							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_()							->     int:



  """simple docstring"""






  try:
    hide_cursor()
    yield
  finally:
    show_cursor()

