



import numpy as np
import qiskit





def      __snake_case	(			_UpperCAmelCase = 8   , _UpperCAmelCase = None				):
    __a						       =				np.random.default_rng(seed=_UpperCAmelCase				)

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

    # Quantum Circuit to simulate BB84
    __a						       =				qiskit.QuantumCircuit(_UpperCAmelCase   , name='''BB84'''				)

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

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

    bbaa_circ.barrier()
    bbaa_circ.measure_all()

    # Simulate the quantum circuit.
    __a						       =				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.
    __a						       =				qiskit.execute(_UpperCAmelCase   , _UpperCAmelCase   , shots=1   , seed_simulator=_UpperCAmelCase				)
    # Returns the result of measurement.
    __a						       =				job.result().get_counts(_UpperCAmelCase				).most_frequent()

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

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


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

 testmod()










from collections import defaultdict





def      __snake_case	(			_UpperCAmelCase   , _UpperCAmelCase				):
    __a						       =				first_str.lower().strip()
    __a						       =				second_str.lower().strip()

    # Remove whitespace
    __a						       =				first_str.replace(''' '''   , ''''''				)
    __a						       =				second_str.replace(''' '''   , ''''''				)

    # Strings of different lengths are not anagrams
    if len(_UpperCAmelCase				) != len(_UpperCAmelCase				):
        return False

    # Default values for count should be 0
    __a						       =				defaultdict(_UpperCAmelCase				)

    # For each character in input strings,
    # increment count in the corresponding
    for i in range(len(_UpperCAmelCase				)				):
        count[first_str[i]] += 1
        count[second_str[i]] -= 1

    return all(_count == 0 for _count in count.values()				)


if __name__ == "__main__":
 from doctest import testmod

 testmod()
 __snake_case						:Any      		=     input('''Enter the first string ''').strip()
 __snake_case						:int      		=     input('''Enter the second string ''').strip()

 __snake_case						:int      		=     check_anagrams(input_a, input_b)
 print(f'{input_a} and {input_b} are {"" if status else "not "}anagrams.')





