import numpy as np
import qiskit



def lowerCamelCase						(     SCREAMING_SNAKE_CASE = 8						,    SCREAMING_SNAKE_CASE = None			):
    '''simple docstring'''







    __UpperCamelCase  :Optional[Any]    						=	np.random.default_rng(seed=SCREAMING_SNAKE_CASE			)

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

    # Quantum Circuit to simulate BB84
    __UpperCamelCase  :Optional[Any]    						=	qiskit.QuantumCircuit(SCREAMING_SNAKE_CASE						,    name='''BB84'''			)

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

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

    bbaa_circ.barrier()
    bbaa_circ.measure_all()

    # Simulate the quantum circuit.
    __UpperCamelCase  :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.
    __UpperCamelCase  :Tuple    						=	qiskit.execute(SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    shots=1						,    seed_simulator=SCREAMING_SNAKE_CASE			)
    # Returns the result of measurement.
    __UpperCamelCase  :int    						=	job.result().get_counts(SCREAMING_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  :List[str]    						=	''''''.join(
        [
            result_bit
            for alice_basis_bit, bob_basis_bit, result_bit in zip(
                SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE			)
            if alice_basis_bit == bob_basis_bit
        ]			)

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


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

    testmod()






import requests
from bsa import BeautifulSoup



def lowerCamelCase						(     SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE			):
    '''simple docstring'''







    __UpperCamelCase  :List[Any]    						=	BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE						,    params=SCREAMING_SNAKE_CASE			).content						,    '''html.parser'''			)
    __UpperCamelCase  :int    						=	soup.find('''div'''						,    attrs={'''class''': '''gs_ri'''}			)
    __UpperCamelCase  :Union[str, Any]    						=	div.find('''div'''						,    attrs={'''class''': '''gs_fl'''}			).find_all('''a'''			)
    return anchors[2].get_text()


if __name__ == "__main__":
    __lowercase											=      {
        '''title''': (
            '''Precisely geometry controlled microsupercapacitors for ultrahigh areal '''
            '''capacitance, volumetric capacitance, and energy density'''
        ),
        '''journal''': '''Chem. Mater.''',
        '''volume''': 30,
        '''pages''': '''3979-3990''',
        '''year''': 2018,
        '''hl''': '''en''',
    }
    print(get_citation('''https://scholar.google.com/scholar_lookup''', params=params))





