
"""simple docstring"""

# Function to print upper half of diamond (pyramid)






def 							A		(       snake_case   :Union[str, Any]	)   ->			Optional[int]:
 for i in range(0       ,      snake_case	):
  for _ in range(0       ,      n - i - 1	):  # printing spaces
   print(' '       ,      end=''	)
  for _ in range(0       ,      i + 1	):  # printing stars
   print('* '       ,      end=''	)
  print()






def 							A		(       snake_case   :Tuple	)   ->			Dict:
 for i in range(snake_case       ,      0       ,      -1	):
  for _ in range(snake_case       ,      0       ,      -1	):  # printing stars
   print('* '       ,      end=''	)
  print()
  for _ in range(n - i + 1       ,      0       ,      -1	):  # printing spaces
   print(' '       ,      end=''	)






def 							A		(       snake_case   :Optional[Any]	)   ->			Optional[int]:
 if n <= 0:
  print('       ...       ....        nothing printing :('	)
  return
 floyd(snake_case	)  # upper half
 reverse_floyd(snake_case	)  # lower half


if __name__ == "__main__":
      print(R"| /\ | |- |  |-  |--| |\  /| |-")
      print(R"|/  \| |- |_ |_  |__| | \/ | |_")
      UpperCamelCase			:       Union[str, Any]									=				1
      while K:
            UpperCamelCase			:       Optional[int]									=				int(input("enter the number and , and see the magic : "))
            print()
            pretty_print(user_number)
            UpperCamelCase			:       Union[str, Any]									=				int(input("press 0 to exit... and 1 to continue..."))

      print("Good Bye...")





"""simple docstring"""

import numpy as np
import qiskit






def 							A		(       snake_case   :int = 8       ,      snake_case   :int | None = None	)   ->			str:
 __UpperCamelCase       						= np.random.default_rng(seed=snake_case	)

 # Roughly 25% of the qubits will contribute to the key.
 # So we take more than we need.
 __UpperCamelCase       						= 6 * key_len
 # Measurement basis for Alice's qubits.
 __UpperCamelCase       						= rng.integers(2       ,      size=snake_case	)
 # The set of states Alice will prepare.
 __UpperCamelCase       						= rng.integers(2       ,      size=snake_case	)
 # Measurement basis for Bob's qubits.
 __UpperCamelCase       						= rng.integers(2       ,      size=snake_case	)

 # Quantum Circuit to simulate BB84
 __UpperCamelCase       						= qiskit.QuantumCircuit(snake_case       ,      name='BB84'	)

 # Alice prepares her qubits according to rules above.
 for index, _ in enumerate(snake_case	):
  if alice_state[index] == 1:
   bbaa_circ.x(snake_case	)
  if alice_basis[index] == 1:
   bbaa_circ.h(snake_case	)
 bbaa_circ.barrier()

 # Bob measures the received qubits according to rules above.
 for index, _ in enumerate(snake_case	):
  if bob_basis[index] == 1:
   bbaa_circ.h(snake_case	)

 bbaa_circ.barrier()
 bbaa_circ.measure_all()

 # Simulate the quantum circuit.
 __UpperCamelCase       						= qiskit.Aer.get_backend('aer_simulator'	)
 # We only need to run one shot because the key is unique.
 # Multiple shots will produce the same key.
 __UpperCamelCase       						= qiskit.execute(snake_case       ,      snake_case       ,      shots=1       ,      seed_simulator=snake_case	)
 # Returns the result of measurement.
 __UpperCamelCase       						= job.result().get_counts(snake_case	).most_frequent()

 # Extracting the generated key from the simulation results.
 # Only keep measurement results where Alice and Bob chose the same basis.
 __UpperCamelCase       						= ''.join(
     [
         result_bit
         for alice_basis_bit, bob_basis_bit, result_bit in zip(
             snake_case       ,      snake_case       ,      snake_case	)
         if alice_basis_bit == bob_basis_bit
     ]	)

 # Get final key. Pad with 0 if too short, otherwise truncate.
 __UpperCamelCase       						= gen_key[:key_len] if len(snake_case	) >= key_len else gen_key.ljust(snake_case       ,      '0'	)
 return key


if __name__ == "__main__":
      print(f'''The generated key is : {bbaa(8, seed=0)}''')
      from doctest import testmod

      testmod()



