{"id":484039,"date":"2026-06-17T20:05:38","date_gmt":"2026-06-17T20:05:38","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=484039"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=484039","title":{"rendered":"\u041a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u044f \u043c\u043e\u043d\u0435\u0442\u043a\u0430 \u043d\u0430 IBM Quantum: \u043a\u0430\u043a \u044f \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u043b \u0432\u044b\u0431\u043e\u0440 \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f \u043d\u0430 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0448\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u043a\u0443\u0434\u0430 \u043f\u043e\u0439\u0442\u0438 \u043d\u0430 \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u0444\u0435\u0439\u043d\u0435\u0439, \u0431\u0430\u0440\u043e\u043c \u0438 \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u043e\u0439. \u0410 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0432\u0437\u0440\u043e\u0441\u043b\u043e: \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 IBM \u0438 \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0444\u0438\u0437\u0438\u043a\u0443. \u0412\u043d\u0443\u0442\u0440\u0438 \u2014 Qiskit, 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 <code>job_id<\/code> \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u0430\u0444\u043e\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043c\u043e\u043d\u0435\u0442\u043a\u0438.<\/p>\n<p> GitHub \u0440\u0435\u043f\u043e <a href=\"https:\/\/github.com\/asherik\/quantum-experiments\" rel=\"noopener noreferrer nofollow\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a><\/p>\n<p>\u0414\u0430, \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>random.choice()<\/code>. \u0412 \u044d\u0442\u043e\u043c \u0438 \u0441\u043c\u044b\u0441\u043b. \u0417\u0430\u0442\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 <code>job_id<\/code>, \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430 IBM Quantum \u0438 \u043c\u043e\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u042d\u0442\u043e \u043d\u0435 \u044f \u0432\u044b\u0431\u0440\u0430\u043b. \u042d\u0442\u043e \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0442\u0430\u043a \u0440\u0435\u0448\u0438\u043b\u0430\u00bb.<\/p>\n<h2>\u0427\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f<\/h2>\n<ol>\n<li>\n<p><strong>Python<\/strong>\u00a0\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00a0<code>qiskit<\/code><\/p>\n<pre><code>pip install qiskit qiskit-aer qiskit-ibm-runtime<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/li>\n<li>\n<p><strong>\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d IBM Quantum<\/strong>. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0435\u0441\u044c \u043d\u0430\u00a0<a href=\"http:\/\/quantum.ibm.com\" rel=\"noopener noreferrer nofollow\">quantum.ibm.com<\/a>, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0<code>IBM_QUANTUM_TOKEN<\/code>. \u0412\u0441\u0451.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c0b\/51e\/f67\/c0b51ef67e4d7faf7b0d90bcf611b2f6.png\" width=\"1909\" height=\"906\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c0b\/51e\/f67\/c0b51ef67e4d7faf7b0d90bcf611b2f6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c0b\/51e\/f67\/c0b51ef67e4d7faf7b0d90bcf611b2f6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u041a\u043e\u0434<\/h3>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f: 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0433\u0435\u0439\u0442 \u0410\u0434\u0430\u043c\u0430\u0440\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c, \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435, 256 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u043e\u0432, \u0431\u0435\u0440\u0451\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0447\u0438\u0441\u043b\u043e \u0438 \u043c\u0430\u043f\u043f\u0438\u043c \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0412 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u044f \u0437\u0430\u0445\u043e\u0434\u0438\u043b \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c. \u041d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u0445\u0435\u043c\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439.  <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">```pythonimport osimport sysimport secretsfrom dataclasses import dataclassfrom collections import Counter# pip install qiskit qiskit-aer qiskit-ibm-runtime## \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e IBM Quantum:#   export IBM_QUANTUM_TOKEN=\"\u0432\u0430\u0448_api_key\"## \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e:#   export IBM_QUANTUM_INSTANCE=\"\u0432\u0430\u0448_CRN_\u0438\u043b\u0438_service_name\"SHOTS = 256QUBITS = 8REGISTER_NAME = \"coin\"# ========================# \u0412\u0410\u0428 \u0421\u041f\u0418\u0421\u041e\u041a \u0412\u0410\u0420\u0418\u0410\u041d\u0422\u041e\u0412# ========================OPTIONS = [    \"\u041a\u043e\u0444\u0435\u0439\u043d\u044f\",    \"\u0411\u0430\u0440\",    \"\u041a\u0438\u043d\u043e\",    \"\u041f\u0440\u043e\u0433\u0443\u043b\u043a\u0430\",    \"\u041d\u0435 \u0438\u0434\u0442\u0438 \u043d\u0438\u043a\u0443\u0434\u0430 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0432\u044b\u0441\u043f\u0430\u0442\u044c\u0441\u044f\",]# ========================@dataclass(frozen=True)class CoinRun:    bitstrings: list[str]    counts: dict[str, int]    backend: str    job_id: str | None = Nonedef validate_options() -&gt; None:    if not OPTIONS:        raise ValueError(\"\u0421\u043f\u0438\u0441\u043e\u043a OPTIONS \u043f\u0443\u0441\u0442. \u0414\u0430\u0436\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0442\u0443\u0442 \u0431\u0435\u0441\u0441\u0438\u043b\u044c\u043d\u0430.\")    max_values = 2 ** QUBITS    if len(OPTIONS) &gt; max_values:        raise ValueError(            f\"\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432: {len(OPTIONS)}. \"            f\"\u041f\u0440\u0438 {QUBITS} \u043a\u0443\u0431\u0438\u0442\u0430\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c {max_values} \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.\"        )def make_circuit():    from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister    q = QuantumRegister(QUBITS, \"q\")    c = ClassicalRegister(QUBITS, REGISTER_NAME)    qc = QuantumCircuit(q, c, name=\"quantum_coin\")    # \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u0443\u0431\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0433\u0434\u0435 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438    # 0 \u0438 1 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441 \u0440\u0430\u0432\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e.    for qubit in q:        qc.h(qubit)    qc.measure(q, c)    return qcdef get_job_id(job) -&gt; str | None:    job_id = getattr(job, \"job_id\", None)    if callable(job_id):        return job_id()    if job_id:        return str(job_id)    return Nonedef get_bits_local() -&gt; CoinRun:    \"\"\"    \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c:    1. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0431\u0443\u0435\u043c AerSimulator.    2. \u0415\u0441\u043b\u0438 qiskit-aer \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c secrets \u043a\u0430\u043a \u0447\u0435\u0441\u0442\u043d\u044b\u0439 fallback.    \"\"\"    try:        from qiskit_aer import AerSimulator        qc = make_circuit()        simulator = AerSimulator()        job = simulator.run(qc, shots=SHOTS, memory=True)        result = job.result()        bitstrings = result.get_memory(qc)        counts = result.get_counts(qc)        return CoinRun(            bitstrings=bitstrings,            counts=dict(counts),            backend=\"AerSimulator \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\",            job_id=get_job_id(job),        )    except ImportError:        bitstrings = [            \"\".join(secrets.choice(\"01\") for _ in range(QUBITS))            for _ in range(SHOTS)        ]        return CoinRun(            bitstrings=bitstrings,            counts=dict(Counter(bitstrings)),            backend=\"Python secrets fallback\",            job_id=None,        )def get_bits_ibm() -&gt; CoinRun:    from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler    from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager    token = os.getenv(\"IBM_QUANTUM_TOKEN\")    instance = os.getenv(\"IBM_QUANTUM_INSTANCE\")    if not token:        raise RuntimeError(            \"\u0422\u043e\u043a\u0435\u043d \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d. \u0423\u043a\u0430\u0436\u0438\u0442\u0435 IBM_QUANTUM_TOKEN \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.\"        )    service_kwargs = {        \"channel\": \"ibm_quantum_platform\",        \"token\": token,    }    if instance:        service_kwargs[\"instance\"] = instance    service = QiskitRuntimeService(**service_kwargs)    backend = service.least_busy(        operational=True,        simulator=False,        min_num_qubits=QUBITS,    )    qc = make_circuit()    pass_manager = generate_preset_pass_manager(        backend=backend,        optimization_level=1,    )    isa_circuit = pass_manager.run(qc)    sampler = Sampler(mode=backend)    job = sampler.run([isa_circuit], shots=SHOTS)    job_id = get_job_id(job)    print(f\"\\n\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 IBM Quantum backend: {backend.name}\")    if job_id:        print(f\"Job ID: {job_id}\")    print(\"\u0416\u0434\u0451\u043c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0412\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439...\")    result = job.result()    pub_result = result[0]    register_data = getattr(pub_result.data, REGISTER_NAME)    bitstrings = register_data.get_bitstrings()    counts = register_data.get_counts()    return CoinRun(        bitstrings=bitstrings,        counts=dict(counts),        backend=backend.name,        job_id=job_id,    )def choose_option(bitstrings: list[str]) -&gt; tuple[str, int, str, int]:    \"\"\"    \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u043c\u0443 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u0443.    \u0412\u0430\u0436\u043d\u043e:    \u043f\u0440\u043e\u0441\u0442\u043e\u0439 value % len(OPTIONS) \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0435\u0440\u0435\u043a\u043e\u0441,    \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0435 \u0434\u0435\u043b\u0438\u0442 2**QUBITS \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430.    \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c rejection sampling:    \u0431\u0435\u0440\u0451\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u043e\u0432\u043d\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f    \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.    \"\"\"    variants_count = len(OPTIONS)    quantum_space = 2 ** QUBITS    usable_space = (quantum_space \/\/ variants_count) * variants_count    for bitstring in bitstrings:        value = int(bitstring, 2)        if value &lt; usable_space:            index = value % variants_count            return OPTIONS[index], index, bitstring, value    # \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u044e\u0434\u0430 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 SHOTS=256,    # \u043d\u043e \u043f\u0443\u0441\u0442\u044c fallback \u0431\u0443\u0434\u0435\u0442.    index = secrets.randbelow(variants_count)    return OPTIONS[index], index, \"fallback\", indexdef print_top_counts(counts: dict[str, int], selected_bitstring: str) -&gt; None:    if not counts:        return    print(\"\\n\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439:\")    print(\"-\" * 40)    selected_count = counts.get(selected_bitstring, 0)    total = sum(counts.values())    if total &gt; 0 and selected_count &gt; 0:        selected_percent = selected_count \/ total * 100        print(            f\"\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0441\u044f {selected_count} \u0440\u0430\u0437 \"            f\"\u0438\u0437 {total} ({selected_percent:.2f}%).\"        )    print(\"\\n\u0422\u043e\u043f-5 \u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u044b\u0445 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u043e\u0432:\")    for bitstring, count in sorted(        counts.items(),        key=lambda item: item[1],        reverse=True,    )[:5]:        print(f\"  {bitstring}: {count}\")def main() -&gt; None:    validate_options()    print(\"\\n\u269b\ufe0f  \u041a\u0412\u0410\u041d\u0422\u041e\u0412\u0410\u042f \u041c\u041e\u041d\u0415\u0422\u041a\u0410 \u269b\ufe0f\")    print(\"=\" * 40)    print(f\"\u041a\u0443\u0431\u0438\u0442\u043e\u0432: {QUBITS}\")    print(f\"\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439: {SHOTS}\")    print(f\"\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432: {len(OPTIONS)}\")    print(\"=\" * 40)    use_ibm = input(\"\u0414\u0451\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 IBM Quantum? (y\/n): \").strip().lower() == \"y\"    if use_ibm:        try:            run = get_bits_ibm()            print(f\"\\n\u2705 \u041e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0441 backend: {run.backend}\")        except Exception as error:            print(f\"\\n\u274c IBM Quantum \u043d\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u043b: {error}\")            print(\"\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c...\")            run = get_bits_local()    else:        run = get_bits_local()        print(f\"\\n\ud83d\udcbb \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: {run.backend}\")    choice, index, selected_bitstring, raw_value = choose_option(run.bitstrings)    print(\"\\n\ud83c\udfb2 \u0420\u0415\u0417\u0423\u041b\u042c\u0422\u0410\u0422 \ud83c\udfb2\")    print(\"=\" * 40)    print(f\"\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: {run.backend}\")    if run.job_id:        print(f\"Job ID: {run.job_id}\")    print(f\"\u0411\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433: {selected_bitstring}\")    print(f\"\u0427\u0438\u0441\u043b\u043e: {raw_value}\")    print(f\"\u0412\u0430\u0440\u0438\u0430\u043d\u0442: {index + 1} \u0438\u0437 {len(OPTIONS)}\")    print(f\"\u0412\u042b\u0411\u041e\u0420: {choice}\")    print(\"=\" * 40)    print_top_counts(run.counts, selected_bitstring)    print(        \"\\n\u042d\u0442\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 random.choice(). \"        \"\u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441 \u043a\u0443\u0431\u0438\u0442\u0430\u043c\u0438, job_id \u0438 \u0447\u0443\u0432\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u0443\u0447\u043d\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438.\"    )if __name__ == \"__main__\":    try:        main()    except KeyboardInterrupt:        print(\"\\n\u0412\u044b\u0431\u043e\u0440 \u043e\u0442\u043c\u0435\u043d\u0451\u043d. \u0421\u0443\u0434\u044c\u0431\u0430 \u043f\u043e\u0434\u043e\u0436\u0434\u0451\u0442.\")        sys.exit(130)```<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c<\/p>\n<pre><code>$env:IBM_QUANTUM_TOKEN=\"\u0432\u0430\u0448\u0442\u043e\u043a\u0435\u043d\"python quantum.py<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0412\u0441\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0430 \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435:<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/db3\/19a\/755\/db319a755329325c0b90426fd13fd451.png\" alt=\"\u043d\u0443 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0434\u0435\u043c \u0432 \u043a\u0438\u043d\u043e)\" title=\"\u043d\u0443 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0434\u0435\u043c \u0432 \u043a\u0438\u043d\u043e)\" width=\"1796\" height=\"887\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/db3\/19a\/755\/db319a755329325c0b90426fd13fd451.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/db3\/19a\/755\/db319a755329325c0b90426fd13fd451.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u043d\u0443 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0434\u0435\u043c \u0432 \u043a\u0438\u043d\u043e)<\/figcaption><\/div>\n<\/figure>\n<p>IBM \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u043e\u0442\u0447\u0438\u0442\u0430\u043b\u0441\u044f \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d3\/dad\/ac8\/6d3dadac8330a63901b44a64aafa3dde.png\" width=\"1869\" height=\"529\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6d3\/dad\/ac8\/6d3dadac8330a63901b44a64aafa3dde.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d3\/dad\/ac8\/6d3dadac8330a63901b44a64aafa3dde.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h3>\n<p>\u0427\u0435\u0441\u0442\u043d\u043e &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0430\u043c \u043d\u0435 \u0437\u043d\u0430\u043b, \u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0443\u0431\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0433\u0435\u0439\u0442 \u0410\u0434\u0430\u043c\u0430\u0440\u0430. \u0415\u0441\u043b\u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u0433\u0440\u0443\u0431\u043e: \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0443\u0431\u0438\u0442 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c <code>0<\/code> \u0438\u043b\u0438 <code>1<\/code> \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u0440\u044f\u0435\u043c \u0441\u0445\u0435\u043c\u0443 256 \u0440\u0430\u0437 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 <code>01010110<\/code>, <code>11100001<\/code>, <code>00011010<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u043e\u0434\u0438\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u043f\u043f\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c<\/h3>\n<pre><code class=\"python\">```python# \u041c\u044f\u0433\u043a\u0438\u0439 \u0440\u0435\u0436\u0438\u043c: \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044cOPTIONS = [    \"\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0410\u043d\u0435\",    \"\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u041a\u0430\u0442\u0435\",    \"\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u041c\u0430\u0448\u0435\",    \"\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u041b\u0435\u043d\u0435\",    \"\u041d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0438\u043a\u043e\u043c\u0443 \u0438 \u0433\u0435\u0440\u043e\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u0435\u0447\u044c \u0441\u043f\u0430\u0442\u044c \u0432 23:00\",]# \u0421\u0432\u0438\u0434\u0430\u043d\u0438\u0435 \u0431\u0435\u0437 \u0432\u044b\u0431\u043e\u0440\u0430 \u043b\u044e\u0434\u0435\u0439 \u043a\u0430\u043a \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043c\u0435\u043d\u044eOPTIONS = [    \"\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0444\u0435\u0439\u043d\u044e\",    \"\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u0432 \u0431\u0430\u0440\",    \"\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u0432 \u043a\u0438\u043d\u043e\",    \"\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0433\u0443\u043b\u044f\u0442\u044c\",    \"\u041d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c \u0432\u0435\u0447\u0435\u0440\",]# \u0420\u0435\u0436\u0438\u043c \u00ab\u044f \u0433\u043e\u043b\u043e\u0434\u043d\u044b\u0439, \u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d\u00bbOPTIONS = [    \"\u041f\u0438\u0446\u0446\u0430\",    \"\u0421\u0443\u0448\u0438\",    \"\u0411\u0443\u0440\u0433\u0435\u0440\",    \"\u0428\u0430\u0443\u0440\u043c\u0430\",    \"\u0413\u0440\u0435\u0447\u043a\u0430: \u0441\u043a\u0443\u0447\u043d\u043e, \u0437\u0430\u0442\u043e \u0431\u0435\u0437 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0440\u0438\u0441\u043a\u043e\u0432\",]# \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432 \u0441\u0443\u0431\u0431\u043e\u0442\u0443 \u0437\u0430 \u043d\u043e\u0443\u0442\u043e\u043cOPTIONS = [    \"\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u0431\u0430\u0433\",    \"\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b\",    \"\u0414\u043e\u043f\u0438\u0441\u0430\u0442\u044c README\",    \"\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0438\u043b \u0442\u0440\u043e\u0433\u0430\u0442\u044c\",    \"\u041f\u043e\u0439\u0442\u0438 \u0433\u0443\u043b\u044f\u0442\u044c, \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u0441\u0432\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\",]# \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u043b\u0438\u0437\u043e\u043cOPTIONS = [    \"\u0417\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0438\u0434, \u0447\u0442\u043e \u0432\u0441\u0451 \u043f\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u043c\",    \"\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b\",    \"\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043b\u043e\u0433\u0438 \u0438 \u043f\u043e\u0436\u0430\u043b\u0435\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c\",    \"\u041e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\",    \"\u0421\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u0443 \u043c\u0435\u043d\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e\u00bb\",]# \u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0435\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430OPTIONS = [    \"\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443\",    \"\u041d\u0430\u0447\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 SaaS \u0438 \u0441\u0442\u0440\u0430\u0434\u0430\u0442\u044c\",    \"\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f IDE\",    \"\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 AI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\",    \"\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u043d\u043e\u0443\u0442\u0431\u0443\u043a \u0438 \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439\",]```<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e: \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u0438, \u0444\u0438\u043b\u044c\u043c\u044b, \u0441\u0442\u0440\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u043f\u0443\u0441\u043a\u0430. \u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0431\u0435\u0441\u043f\u0440\u0438\u0441\u0442\u0440\u0430\u0441\u0442\u0435\u043d \u043a \u0432\u044b\u0431\u043e\u0440\u0443 \u043c\u0435\u0436\u0434\u0443 \u0448\u0430\u0443\u0440\u043c\u043e\u0439 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u043c.  <\/p>\n<h3>\u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0436\u0434\u0443<\/h3>\n<ul>\n<li>\n<p>\u0412\u0430\u0448\u0438 \u0441\u0430\u043c\u044b\u0435 \u0431\u0435\u0437\u0443\u043c\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438\u00a0<code>OPTIONS<\/code><\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b job&#8217;\u043e\u0432 \u0438\u0437 IBM Quantum<\/p>\n<\/li>\n<li>\n<p>\u0421\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0435 \u0445\u043e\u043b\u0438\u0432\u0430\u0440\u044b, \u043a\u0443\u0434\u0430 \u0431\u0435\u0437 \u043d\u0438\u0445 \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<p>\u041b\u044e\u0431\u044b\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0437\u0438\u0438 \u043a \u0432\u044b\u0431\u043e\u0440\u0443 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u043c\u043d\u0435, \u0430 \u0432 \u0418\u043d\u0441\u0442\u0438\u0442\u0443\u0442 \u041d\u0438\u043b\u044c\u0441\u0430 \u0411\u043e\u0440\u0430. \u042f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \ud83d\ude42<\/p>\n<p>GitHub \u0440\u0435\u043f\u043e <a href=\"https:\/\/github.com\/asherik\/quantum-experiments\" rel=\"noopener noreferrer nofollow\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/a><\/p>\n<p>\u0423\u0434\u0430\u0447\u0438 \u0432 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445!<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1048848\/\">https:\/\/habr.com\/ru\/articles\/1048848\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0448\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u043a\u0443\u0434\u0430 \u043f\u043e\u0439\u0442\u0438 \u043d\u0430 \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u0444\u0435\u0439\u043d\u0435\u0439, \u0431\u0430\u0440\u043e\u043c \u0438 \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u043e\u0439. \u0410 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0432\u0437\u0440\u043e\u0441\u043b\u043e: \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 IBM \u0438 \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0444\u0438\u0437\u0438\u043a\u0443. \u0412\u043d\u0443\u0442\u0440\u0438 \u2014 Qiskit, 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 job_id \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u0430\u0444\u043e\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043c\u043e\u043d\u0435\u0442\u043a\u0438. GitHub \u0440\u0435\u043f\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435\u0414\u0430, \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c random.choice(). \u0412 \u044d\u0442\u043e\u043c \u0438 \u0441\u043c\u044b\u0441\u043b. \u0417\u0430\u0442\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 job_id, \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430 IBM Quantum \u0438 \u043c\u043e\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u042d\u0442\u043e \u043d\u0435 \u044f \u0432\u044b\u0431\u0440\u0430\u043b. \u042d\u0442\u043e \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0442\u0430\u043a \u0440\u0435\u0448\u0438\u043b\u0430\u00bb.\u0427\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044fPython\u00a0\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00a0qiskitpip install qiskit qiskit-aer qiskit-ibm-runtime\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d IBM Quantum. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0435\u0441\u044c \u043d\u0430\u00a0quantum.ibm.com, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0IBM_QUANTUM_TOKEN. \u0412\u0441\u0451.\u041a\u043e\u0434\u0421\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f: 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0433\u0435\u0439\u0442 \u0410\u0434\u0430\u043c\u0430\u0440\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c, \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435, 256 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u043e\u0432, \u0431\u0435\u0440\u0451\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0447\u0438\u0441\u043b\u043e \u0438 \u043c\u0430\u043f\u043f\u0438\u043c \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.\u0412 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u044f \u0437\u0430\u0445\u043e\u0434\u0438\u043b \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c. \u041d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u0445\u0435\u043c\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439.  \u041a\u043e\u0434 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c:&#171;`pythonimport osimport sysimport secretsfrom dataclasses import dataclassfrom collections import Counter# pip install qiskit qiskit-aer qiskit-ibm-runtime## \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e IBM Quantum:#   export IBM_QUANTUM_TOKEN=&#187;\u0432\u0430\u0448_api_key&#187;## \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e:#   export IBM_QUANTUM_INSTANCE=&#187;\u0432\u0430\u0448_CRN_\u0438\u043b\u0438_service_name&#187;SHOTS = 256QUBITS = 8REGISTER_NAME = &#171;coin&#187;# ========================# \u0412\u0410\u0428 \u0421\u041f\u0418\u0421\u041e\u041a \u0412\u0410\u0420\u0418\u0410\u041d\u0422\u041e\u0412# ========================OPTIONS = [    &#171;\u041a\u043e\u0444\u0435\u0439\u043d\u044f&#187;,    &#171;\u0411\u0430\u0440&#187;,    &#171;\u041a\u0438\u043d\u043e&#187;,    &#171;\u041f\u0440\u043e\u0433\u0443\u043b\u043a\u0430&#187;,    &#171;\u041d\u0435 \u0438\u0434\u0442\u0438 \u043d\u0438\u043a\u0443\u0434\u0430 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0432\u044b\u0441\u043f\u0430\u0442\u044c\u0441\u044f&#187;,]# ========================@dataclass(frozen=True)class CoinRun:    bitstrings: list[str]    counts: dict[str, int]    backend: str    job_id: str | None = Nonedef validate_options() -&gt; None:    if not OPTIONS:        raise ValueError(&#171;\u0421\u043f\u0438\u0441\u043e\u043a OPTIONS \u043f\u0443\u0441\u0442. \u0414\u0430\u0436\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0442\u0443\u0442 \u0431\u0435\u0441\u0441\u0438\u043b\u044c\u043d\u0430.&#187;)    max_values = 2 ** QUBITS    if len(OPTIONS) &gt; max_values:        raise ValueError(            f&#187;\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432: {len(OPTIONS)}. &#187;            f&#187;\u041f\u0440\u0438 {QUBITS} \u043a\u0443\u0431\u0438\u0442\u0430\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c {max_values} \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.&#187;        )def make_circuit():    from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister    q = QuantumRegister(QUBITS, &#171;q&#187;)    c = ClassicalRegister(QUBITS, REGISTER_NAME)    qc = QuantumCircuit(q, c, name=&#187;quantum_coin&#187;)    # \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u0443\u0431\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0433\u0434\u0435 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438    # 0 \u0438 1 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441 \u0440\u0430\u0432\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e.    for qubit in q:        qc.h(qubit)    qc.measure(q, c)    return qcdef get_job_id(job) -&gt; str | None:    job_id = getattr(job, &#171;job_id&#187;, None)    if callable(job_id):        return job_id()    if job_id:        return str(job_id)    return Nonedef get_bits_local() -&gt; CoinRun:    &#171;&#187;&#187;    \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c:    1. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0431\u0443\u0435\u043c AerSimulator.    2. \u0415\u0441\u043b\u0438 qiskit-aer \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c secrets \u043a\u0430\u043a \u0447\u0435\u0441\u0442\u043d\u044b\u0439 fallback.    &#171;&#187;&#187;    try:        from qiskit_aer import AerSimulator        qc = make_circuit()        simulator = AerSimulator()        job = simulator.run(qc, shots=SHOTS, memory=True)        result = job.result()        bitstrings = result.get_memory(qc)        counts = result.get_counts(qc)        return CoinRun(            bitstrings=bitstrings,            counts=dict(counts),            backend=&#187;AerSimulator \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e&#187;,            job_id=get_job_id(job),        )    except ImportError:        bitstrings = [            &#171;&#187;.join(secrets.choice(&#171;01&#8243;) for _ in range(QUBITS))            for _ in range(SHOTS)        ]        return CoinRun(            bitstrings=bitstrings,            counts=dict(Counter(bitstrings)),            backend=&#187;Python secrets fallback&#187;,            job_id=None,        )def get_bits_ibm() -&gt; CoinRun:    from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler    from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager    token = os.getenv(&#171;IBM_QUANTUM_TOKEN&#187;)    instance = os.getenv(&#171;IBM_QUANTUM_INSTANCE&#187;)    if not token:        raise RuntimeError(            &#171;\u0422\u043e\u043a\u0435\u043d \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d. \u0423\u043a\u0430\u0436\u0438\u0442\u0435 IBM_QUANTUM_TOKEN \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.&#187;        )    service_kwargs = {        &#171;channel&#187;: &#171;ibm_quantum_platform&#187;,        &#171;token&#187;: token,    }    if instance:        service_kwargs[&#171;instance&#187;] = instance    service = QiskitRuntimeService(**service_kwargs)    backend = service.least_busy(        operational=True,        simulator=False,        min_num_qubits=QUBITS,    )    qc = make_circuit()    pass_manager = generate_preset_pass_manager(        backend=backend,        optimization_level=1,    )    isa_circuit = pass_manager.run(qc)    sampler = Sampler(mode=backend)    job = sampler.run([isa_circuit], shots=SHOTS)    job_id = get_job_id(job)    print(f&#187;\\n\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430 IBM Quantum backend: {backend.name}&#187;)    if job_id:        print(f&#187;Job ID: {job_id}&#187;)    print(&#171;\u0416\u0434\u0451\u043c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0412\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439&#8230;&#187;)    result = job.result()    pub_result = result[0]    register_data = getattr(pub_result.data, REGISTER_NAME)    bitstrings = register_data.get_bitstrings()    counts = register_data.get_counts()    return CoinRun(        bitstrings=bitstrings,        counts=dict(counts),        backend=backend.name,        job_id=job_id,    )def choose_option(bitstrings: list[str]) -&gt; tuple[str, int, str, int]:    &#171;&#187;&#187;    \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u043c\u0443 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u0443.    \u0412\u0430\u0436\u043d\u043e:    \u043f\u0440\u043e\u0441\u0442\u043e\u0439 value % len(OPTIONS) \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0435\u0440\u0435\u043a\u043e\u0441,    \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0435 \u0434\u0435\u043b\u0438\u0442 2**QUBITS \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430.    \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c rejection sampling:    \u0431\u0435\u0440\u0451\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u043e\u0432\u043d\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f    \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.    &#171;&#187;&#187;    variants_count = len(OPTIONS)    quantum_space = 2 ** QUBITS    usable_space = (quantum_space \/\/ variants_count) * variants_count    for bitstring in bitstrings:        value = int(bitstring, 2)        if value &lt; usable_space:            index = value % variants_count            return OPTIONS[index], index, bitstring, value    # \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u044e\u0434\u0430 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 SHOTS=256,    # \u043d\u043e \u043f\u0443\u0441\u0442\u044c fallback \u0431\u0443\u0434\u0435\u0442.    index = secrets.randbelow(variants_count)    return OPTIONS[index], index, &#171;fallback&#187;, indexdef print_top_counts(counts: dict[str, int], selected_bitstring: str) -&gt; None:    if not counts:        return    print(&#171;\\n\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439:&#187;)    print(&#171;-&#187; * 40)    selected_count = counts.get(selected_bitstring, 0)    total = sum(counts.values())    if total &gt; 0 and selected_count &gt; 0:        selected_percent = selected_count \/ total * 100        print(            f&#187;\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0441\u044f {selected_count} \u0440\u0430\u0437 &#187;            f&#187;\u0438\u0437 {total} ({selected_percent:.2f}%).&#187;        )    print(&#171;\\n\u0422\u043e\u043f-5 \u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u044b\u0445 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u043e\u0432:&#187;)    for bitstring, count in sorted(        counts.items(),        key=lambda item: item[1],        reverse=True,    )[:5]:        print(f&#187;  {bitstring}: {count}&#187;)def main() -&gt; None:    validate_options()    print(&#171;\\n\u269b\ufe0f  \u041a\u0412\u0410\u041d\u0422\u041e\u0412\u0410\u042f \u041c\u041e\u041d\u0415\u0422\u041a\u0410 \u269b\ufe0f&#187;)    print(&#171;=&#187; * 40)    print(f&#187;\u041a\u0443\u0431\u0438\u0442\u043e\u0432: {QUBITS}&#187;)    print(f&#187;\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439: {SHOTS}&#187;)    print(f&#187;\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432: {len(OPTIONS)}&#187;)    print(&#171;=&#187; * 40)    use_ibm = input(&#171;\u0414\u0451\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 IBM Quantum? (y\/n): &#171;).strip().lower() == &#171;y&#187;    if use_ibm:        try:            run = get_bits_ibm()            print(f&#187;\\n\u2705 \u041e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0441 backend: {run.backend}&#187;)        except Exception as error:            print(f&#187;\\n\u274c IBM Quantum \u043d\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u043b: {error}&#187;)            print(&#171;\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c&#8230;&#187;)            run = get_bits_local()    else:        run = get_bits_local()        print(f&#187;\\n\ud83d\udcbb \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: {run.backend}&#187;)    choice, index, selected_bitstring, raw_value = choose_option(run.bitstrings)    print(&#171;\\n\ud83c\udfb2 \u0420\u0415\u0417\u0423\u041b\u042c\u0422\u0410\u0422 \ud83c\udfb2&#187;)    print(&#171;=&#187; * 40)    print(f&#187;\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: {run.backend}&#187;)    if run.job_id:        print(f&#187;Job ID: {run.job_id}&#187;)    print(f&#187;\u0411\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433: {selected_bitstring}&#187;)    print(f&#187;\u0427\u0438\u0441\u043b\u043e: {raw_value}&#187;)    print(f&#187;\u0412\u0430\u0440\u0438\u0430\u043d\u0442: {index + 1} \u0438\u0437 {len(OPTIONS)}&#187;)    print(f&#187;\u0412\u042b\u0411\u041e\u0420: {choice}&#187;)    print(&#171;=&#187; * 40)    print_top_counts(run.counts, selected_bitstring)    print(        &#171;\\n\u042d\u0442\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 random.choice(). &#187;        &#171;\u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441 \u043a\u0443\u0431\u0438\u0442\u0430\u043c\u0438, job_id \u0438 \u0447\u0443\u0432\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u0443\u0447\u043d\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438.&#187;    )if __name__ == &#171;__main__&#187;:    try:        main()    except KeyboardInterrupt:        print(&#171;\\n\u0412\u044b\u0431\u043e\u0440 \u043e\u0442\u043c\u0435\u043d\u0451\u043d. \u0421\u0443\u0434\u044c\u0431\u0430 \u043f\u043e\u0434\u043e\u0436\u0434\u0451\u0442.&#187;)        sys.exit(130)&#171;`\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c$env:IBM_QUANTUM_TOKEN=&#187;\u0432\u0430\u0448\u0442\u043e\u043a\u0435\u043d&#187;python quantum.py\u0412 \u0438\u0442\u043e\u0433\u0435 \u0412\u0441\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0430 \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435:\u043d\u0443 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0434\u0435\u043c \u0432 \u043a\u0438\u043d\u043e)IBM \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u043e\u0442\u0447\u0438\u0442\u0430\u043b\u0441\u044f \u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0427\u0435\u0441\u0442\u043d\u043e &#8212; \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0430\u043c \u043d\u0435 \u0437\u043d\u0430\u043b, \u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f.\u0421\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f:\u0421\u043e\u0437\u0434\u0430\u0451\u043c 8 \u043a\u0443\u0431\u0438\u0442\u043e\u0432.\u041d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0443\u0431\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0433\u0435\u0439\u0442 \u0410\u0434\u0430\u043c\u0430\u0440\u0430. \u0415\u0441\u043b\u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u0433\u0440\u0443\u0431\u043e: \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0443\u0431\u0438\u0442 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c 0 \u0438\u043b\u0438 1 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e.\u0418\u0437\u043c\u0435\u0440\u044f\u0435\u043c \u0441\u0445\u0435\u043c\u0443 256 \u0440\u0430\u0437 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 01010110, 11100001, 00011010.\u0411\u0435\u0440\u0451\u043c \u043e\u0434\u0438\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0442\u0441\u0442\u0440\u0438\u043d\u0433.\u041f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0447\u0438\u0441\u043b\u043e.\u041c\u0430\u043f\u043f\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.\u041a\u0430\u043a\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c&#171;`python# \u041c\u044f\u0433\u043a\u0438\u0439 \u0440\u0435\u0436\u0438\u043c: \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044cOPTIONS = [    &#171;\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0410\u043d\u0435&#187;,    &#171;\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u041a\u0430\u0442\u0435&#187;,    &#171;\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u041c\u0430\u0448\u0435&#187;,    &#171;\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u041b\u0435\u043d\u0435&#187;,    &#171;\u041d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0438\u043a\u043e\u043c\u0443 \u0438 \u0433\u0435\u0440\u043e\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u0435\u0447\u044c \u0441\u043f\u0430\u0442\u044c \u0432 23:00&#187;,]# \u0421\u0432\u0438\u0434\u0430\u043d\u0438\u0435 \u0431\u0435\u0437 \u0432\u044b\u0431\u043e\u0440\u0430 \u043b\u044e\u0434\u0435\u0439 \u043a\u0430\u043a \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043c\u0435\u043d\u044eOPTIONS = [    &#171;\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u0444\u0435\u0439\u043d\u044e&#187;,    &#171;\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u0432 \u0431\u0430\u0440&#187;,    &#171;\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u0432 \u043a\u0438\u043d\u043e&#187;,    &#171;\u041f\u043e\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0433\u0443\u043b\u044f\u0442\u044c&#187;,    &#171;\u041d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c \u0432\u0435\u0447\u0435\u0440&#187;,]# \u0420\u0435\u0436\u0438\u043c \u00ab\u044f \u0433\u043e\u043b\u043e\u0434\u043d\u044b\u0439, \u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d\u00bbOPTIONS = [    &#171;\u041f\u0438\u0446\u0446\u0430&#187;,    &#171;\u0421\u0443\u0448\u0438&#187;,    &#171;\u0411\u0443\u0440\u0433\u0435\u0440&#187;,    &#171;\u0428\u0430\u0443\u0440\u043c\u0430&#187;,    &#171;\u0413\u0440\u0435\u0447\u043a\u0430: \u0441\u043a\u0443\u0447\u043d\u043e, \u0437\u0430\u0442\u043e \u0431\u0435\u0437 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0440\u0438\u0441\u043a\u043e\u0432&#187;,]# \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432 \u0441\u0443\u0431\u0431\u043e\u0442\u0443 \u0437\u0430 \u043d\u043e\u0443\u0442\u043e\u043cOPTIONS = [    &#171;\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u0431\u0430\u0433&#187;,    &#171;\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b&#187;,    &#171;\u0414\u043e\u043f\u0438\u0441\u0430\u0442\u044c README&#187;,    &#171;\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0438\u043b \u0442\u0440\u043e\u0433\u0430\u0442\u044c&#187;,    &#171;\u041f\u043e\u0439\u0442\u0438 \u0433\u0443\u043b\u044f\u0442\u044c, \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u0441\u0432\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a&#187;,]# \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u043b\u0438\u0437\u043e\u043cOPTIONS = [    &#171;\u0417\u0430\u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0438\u0434, &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-484039","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/484039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=484039"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/484039\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=484039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=484039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=484039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}