





import numpy as np
import qiskit







def       UpperCAmelCase							(     _lowerCamelCase      :  int = 8			,   _lowerCamelCase      :  int | None = None     ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					np.random.default_rng(seed=_lowerCamelCase     )

						# Roughly 25% of the qubits will contribute to the key.
						# So we take more than we need.
						SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					6 * key_len
						# Measurement basis for Alice's qubits.
						SCREAMING_SNAKE_CASE__     :				List[str]   =					rng.integers(2			,   size=_lowerCamelCase     )
						# The set of states Alice will prepare.
						SCREAMING_SNAKE_CASE__     :				str   =					rng.integers(2			,   size=_lowerCamelCase     )
						# Measurement basis for Bob's qubits.
						SCREAMING_SNAKE_CASE__     :				List[str]   =					rng.integers(2			,   size=_lowerCamelCase     )

						# Quantum Circuit to simulate BB84
						SCREAMING_SNAKE_CASE__     :				Tuple   =					qiskit.QuantumCircuit(_lowerCamelCase			,   name="BB84"     )

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

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

						bbaa_circ.barrier()
						bbaa_circ.measure_all()

						# Simulate the quantum circuit.
						SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					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.
						SCREAMING_SNAKE_CASE__     :				Tuple   =					qiskit.execute(_lowerCamelCase			,   _lowerCamelCase			,   shots=1			,   seed_simulator=_lowerCamelCase     )
						# Returns the result of measurement.
						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					job.result().get_counts(_lowerCamelCase     ).most_frequent()

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

						# Get final key. Pad with 0 if too short, otherwise truncate.
						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					gen_key[:key_len] if len(_lowerCamelCase     ) >= key_len else gen_key.ljust(_lowerCamelCase			,   "0"     )
						return key


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

				testmod()






from __future__ import annotations

from fractions import Fraction







def       UpperCAmelCase							(     _lowerCamelCase      :  int			,   _lowerCamelCase      :  int     ):





						'''simple docstring'''


						return (
						    num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den
						)







def       UpperCAmelCase							(     _lowerCamelCase      :  int     ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__     :				int   =					[]
						SCREAMING_SNAKE_CASE__     :				str   =					11
						SCREAMING_SNAKE_CASE__     :				Any   =					int("1" + "0" * digit_len     )
						for num in range(_lowerCamelCase			,   _lowerCamelCase     ):
												while den <= 99:
																		if (num != den) and (num % 10 == den // 10) and (den % 10 != 0):
																								if is_digit_cancelling(_lowerCamelCase			,   _lowerCamelCase     ):
																														solutions.append(f"""{num}/{den}"""     )
																		den += 1
												num += 1
												SCREAMING_SNAKE_CASE__     :				str   =					10
						return solutions







def       UpperCAmelCase							(     _lowerCamelCase      :  int = 2     ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					1.0
						for fraction in fraction_list(_lowerCamelCase     ):
												SCREAMING_SNAKE_CASE__     :				Any   =					Fraction(_lowerCamelCase     )
												result *= frac.denominator / frac.numerator
						return int(_lowerCamelCase     )


if __name__ == "__main__":
				print(solution())