QuanBench+: A Unified Multi-Framework Benchmark for LLM-Based Quantum Code Generation
Paper • 2604.08570 • Published • 125
task_id stringlengths 2 2 | complete_prompt stringlengths 220 992 | entry_point stringlengths 3 30 | canonical_solution stringlengths 181 2.62k | category stringclasses 3
values | framework stringclasses 3
values | canonical_output listlengths 2 256 |
|---|---|---|---|---|---|---|
01 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def grover_search_oracle_00() ->QuantumCircuit:
"""
Implement a quantum circuit using grover algorithm to find oracle |00> using qiskit, return the QuantumCircuit after mea... | grover_search_oracle_00 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def grover_search_oracle_00() ->QuantumCircuit:
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h([0, 1])
qc.x([0, 1])
qc.cz(0, 1)
qc.x([0, 1])
qc.h([0, 1])
qc.z([0,... | QUANTUM_ALGO | qiskit | [
1,
0,
0,
0
] |
02 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit3() ->QuantumCircuit:
"""
Implementation a quantum circuit to create the state ψ = √(1/2)(|011⟩ − |100⟩) using qiskit, return ... | generate_quantum_state_qubit3 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit3() -> QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.h(2)
qc.x(1)
qc.cx(2,1)
qc.cx(1,0)
qc.z(2)
qc.measure([0,1,2], [0,1,2])
return qc | STATE_PREPARATION | qiskit | [
0,
0,
0,
0.48,
0.52,
0,
0,
0
] |
03 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def grover_3SAT() ->QuantumCircuit:
"""
Implement a quantum circuit using grover algorithm to solve the 3 SAT problem with 3-CNF formula {((x1) | (x2) | (x3))... | grover_3SAT | from qiskit.circuit.library import PhaseOracle
from qiskit_algorithms import Grover, AmplificationProblem
from qiskit.primitives import Sampler
def grover_3SAT():
"""
Solve 3-SAT problem using Grover's Algorithm (compatible with new Qiskit version).
Formula:
((x1) ∨ (x2) ∨ (x3)) ∧
(¬x1 ∨ x2 ∨ x3) ∧... | QUANTUM_ALGO | qiskit | [
0,
0,
0.5028,
0,
0,
0,
0.4972,
0
] |
04 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def qaoa_maxcut_ansatz(G, beta, gamma) ->QuantumCircuit:
"""
Implement a quantum circuit using QAOA algorithm to solve the maxcut problem with the graph ([[0,... | qaoa_maxcut_ansatz | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def qaoa_maxcut_ansatz(G, beta, gamma) -> QuantumCircuit:
n = len(G.nodes)
p = len(beta)
qr = QuantumRegister(n, 'q')
cr = ClassicalRegister(n, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(qr)
for i in range(p):
... | QUANTUM_ALGO | qiskit | [
0.173,
0.022,
0.025,
0.009,
0.019,
0.002,
0.003,
0,
0.041,
0.032,
0.035,
0.03,
0.02,
0.027,
0.032,
0.051,
0.04,
0.035,
0.017,
0.04,
0.03,
0.028,
0.031,
0.028,
0,
0.004,
0.007,
0.024,
0.002,
0.024,
0.03,
0.139
] |
06 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_zaxis(unknown_state: QuantumCircuit) ->QuantumCircuit:
"""
Implement a quantum circuit using the SWAP test algorithm to estimate the angle θ (in radians)... | swaptest_zaxis | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_zaxis(unknown_state: QuantumCircuit) ->QuantumCircuit:
qr = QuantumRegister(3, 'q')
cr = ClassicalRegister(1, 'c')
qc = QuantumCircuit(qr, cr)
qc = qc.compose(unknown_state, [qr[1]])
qc.h(qr[0])
qc.csw... | QUANTUM_ALGO | qiskit | [
0.739,
0.261
] |
07 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_individual() ->QuantumCircuit:
"""
Implement a quantum circuit using the SWAP test with individual ancilla qubits for each qubit-to-qubit comparison betw... | swaptest_individual | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_individual() ->QuantumCircuit:
qr = QuantumRegister(9, 'q')
cr = ClassicalRegister(3, 'c')
qc = QuantumCircuit(qr, cr)
qc.x(qr[1])
qc.x(qr[2])
qc.h(qr[6])
qc.h(qr[7])
qc.h(qr[8])
qc.cswap(qr[6],... | QUANTUM_ALGO | qiskit | [
0.248,
0,
0.237,
0,
0.258,
0,
0.257,
0
] |
08 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from math import pi
def qft_6() ->QuantumCircuit:
"""
Implement a 6 qubit quantum fourier transform circuit, and return the QuantumCircuit after measure all qubits.
... | qft_6 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from math import pi
def qft_6():
"""QFT on 6 qubits"""
qr = QuantumRegister(6, 'q')
cr = ClassicalRegister(6, 'c')
qc = QuantumCircuit(qr,cr)
for i in range(5, -1, -1):
qc.h(qr[i])
for j in range(i):
q... | QUANTUM_ALGO | qiskit | [
0.02,
0.016,
0.013,
0.012,
0.019,
0.013,
0.012,
0.017,
0.009,
0.02,
0.016,
0.024,
0.009,
0.02,
0.016,
0.012,
0.008,
0.013,
0.009,
0.02,
0.012,
0.017,
0.014,
0.02,
0.016,
0.019,
0.011,
0.013,
0.017,
0.013,
0.017,
0.016,
0.012,
0.017,
0.016,
0.022,... |
09 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def qpe_x_gate() ->QuantumCircuit:
"""
Implement a quantum circuit to perform Quantum Phase Estimation using 3 counting qubits and 1 target qubit to estimate the phas... | qpe_x_gate | from qiskit import QuantumCircuit
from qiskit.circuit.library import QFT
def qpe_x_gate(n_count=3):
qc = QuantumCircuit(n_count + 1, n_count)
qc.h(range(n_count))
qc.x(n_count)
for qubit in range(n_count):
repetitions = 2**qubit
for _ in range(repetitions):
qc.cx(qubit, n_c... | QUANTUM_ALGO | qiskit | [
0.542,
0,
0,
0,
0.458,
0,
0,
0
] |
10 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
from qiskit.quantum_info import Statevector
from scipy.linalg import expm
from qiskit.circuit.library import UnitaryGate
from qiskit.circuit.library import QFT
from ... | HHL_4x4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
from qiskit.quantum_info import Statevector
from scipy.linalg import expm
from qiskit.circuit.library import UnitaryGate
from qiskit.circuit.library import QFT
from qiskit.circuit.library import RYGate
import math
def HHL_4x4() ->... | QUANTUM_ALGO | qiskit | [
0.396,
0.475,
0,
0.129
] |
11 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Deutsch_Jozsa_Balance_4() ->QuantumCircuit:
"""
Implement a quantum circuit use DeutschJozsa algorithm to solve a oracle with bitstring "1100", return the QuantumCir... | Deutsch_Jozsa_Balance_4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def Deutsch_Jozsa_Balance_4() -> QuantumCircuit:
def dj_oracle(case, n):
oracle_qc = QuantumCircuit(n+1)
if case == "balanced":
b = np.random.randint(1,2**n)
b_str = '1100'
... | QUANTUM_ALGO | qiskit | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] |
12 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Deutsch_Jozsa_Constant_4() ->QuantumCircuit:
"""
Implement a quantum circuit use DeutschJozsa algorithm to solve a oracle with bitstring "0000", return the QuantumCi... | Deutsch_Jozsa_Constant_4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def Deutsch_Jozsa_Constant_4() -> QuantumCircuit:
def dj_oracle(case, n):
oracle_qc = QuantumCircuit(n+1)
if case == "balanced":
b = np.random.randint(1,2**n)
b_str = '1100'
... | QUANTUM_ALGO | qiskit | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
13 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_11() ->QuantumCircuit:
"""
Implement a quantum circuit using Simon's algorithm for the case where:
- The input bit length n = 2
- The hi... | Simon_11 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_11() ->QuantumCircuit:
qc = QuantumCircuit(4,2)
qc.h(0)
qc.h(1)
for i in range(2):
qc.cx(i,2)
qc.cx(i,3)
qc.h(i)
qc.measure(2,0)
qc.measure(3,1)
return qc | QUANTUM_ALGO | qiskit | [
0.503,
0,
0,
0.497
] |
14 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_110() ->QuantumCircuit:
"""
Implement a quantum circuit using Simon's algorithm for the case:
- The input bit length n = 3
- The hidden ... | Simon_110 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_110() ->QuantumCircuit:
qc = QuantumCircuit(6,3)
for i in range(3):
qc.h(i)
for i in range(3):
qc.cx(i,i+3)
qc.cx(1,4)
qc.cx(1,5)
for i in range(3):
qc.h(i)
qc.measure(i,i)
retur... | QUANTUM_ALGO | qiskit | [
0.271,
0.239,
0,
0,
0,
0,
0.244,
0.246
] |
15 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Hadmard_Test_h() ->QuantumCircuit:
"""
Implement a 2 qubit Hadmard test quantum circuit for |+> state, return the QuantumCircuit after measure the ancilla qubit.
... | Hadmard_Test_h | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Hadmard_Test_h() ->QuantumCircuit:
qc = QuantumCircuit(2,1)
qc.h(0)
qc.h(1)
qc.ch(0,1)
qc.h(0)
qc.measure(0,0)
return qc | QUANTUM_ALGO | qiskit | [
0.847,
0.153
] |
16 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bell_State() ->QuantumCircuit:
"""
Implement a quantum circuit with Bell State, return the QuantumCircuit after measure all qubits.
""" | Bell_State | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bell_State() ->QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.h(0)
qc.cx(0,1)
qc.measure(0,0)
qc.measure(1,1)
return qc | QUANTUM_ALGO | qiskit | [
0.5,
0,
0,
0.5
] |
17 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def GHZ() ->QuantumCircuit:
"""
Implement a 3 qubits GHZ state quantum circuit, return the QuantumCircuit after measure all qubits.
""" | GHZ | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def GHZ() ->QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.h(0)
qc.cx(0,1)
qc.cx(1,2)
qc.measure([0,1,2],[0,1,2])
return qc | QUANTUM_ALGO | qiskit | [
0.493,
0,
0,
0,
0,
0,
0,
0.507
] |
18 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from numpy import pi
def Quantum_Teleportation() ->QuantumCircuit:
"""
Implement a 3 qubits Quantum_Teleportation, Alice own Qubit 0 and Qubit 1, Bob own Qubit2. Alice's i... | Quantum_Teleportation | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from numpy import pi
def Quantum_Teleportation() ->QuantumCircuit:
qc = QuantumCircuit(3,1)
qc.rx(pi/2,0)
qc.h(1)
qc.cx(1,2)
qc.cx(0,1)
qc.h(0)
qc.cx(1,2)
qc.cz(0,2)
qc.measure(2,0)
return qc | QUANTUM_ALGO | qiskit | [
0.462,
0.538
] |
19 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit5() ->QuantumCircuit:
"""
implementation a quantum circuit to create the state ψ = √(1/2)(|00110⟩ + |00101⟩) using qiskit, ret... | generate_quantum_state_qubit5 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit5() ->QuantumCircuit:
qc = QuantumCircuit(5,5)
qc.x(2)
qc.h(3)
qc.cx(3,4)
qc.x(4)
qc.measure([0,1,2,3,4],[4,3,2,1,0])
return qc | QUANTUM_ALGO | qiskit | [
0,
0,
0,
0,
0,
0.496,
0.504,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
20 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bernstein_Vazirani_011() ->QuantumCircuit:
"""
Implement the Bernstein–Vazirani algorithm for a 3-bit hidden string a = '011'.
Return the QuantumCircuit afte... | Bernstein_Vazirani_011 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bernstein_Vazirani_011() ->QuantumCircuit:
qc = QuantumCircuit(4,3)
qc.x(3)
qc.h([0,1,2,3])
qc.cx(1,3)
qc.cx(2,3)
qc.h([0,1,2])
qc.measure([0,1,2],[0,1,2])
return qc | QUANTUM_ALGO | qiskit | [
0,
0,
0,
0,
0,
0,
1,
0
] |
21 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def MAJ_3() ->QuantumCircuit:
"""
Implement a 3-input quantum Majority (MAJ) gate using CNOT and CCNOT (Toffoli) gates.
The circuit takes as input three qubits:
... | MAJ_3 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def MAJ_3() ->QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.cx(0, 1)
qc.cx(0, 2)
qc.ccx(1, 2, 0)
qc.measure([0, 1, 2], [0, 1, 2])
return qc | QUANTUM_ALGO | qiskit | [
1,
0,
0,
0,
0,
0,
0,
0
] |
22 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Qadd() ->QuantumCircuit:
"""
Implement a quantum Adder for a = 100, b = 001, and c0 = 1. Return the QuantumCircuit after measure the result qubits (4 qubits).
""" | Qadd | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def Qadd() -> QuantumCircuit:
qc = QuantumCircuit(8, 4)
qc.x(0)
qc.x(1)
qc.x(6)
def MAJ(qc,ci,bi,ai):
qc.cx(ai,bi)
qc.cx(ai,ci)
qc.ccx(bi,ci,ai)
return qc
def UMA(qc, ci, bi, ai):
qc.cc... | QUANTUM_ALGO | qiskit | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
23 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def QSub() ->QuantumCircuit:
"""
Implement a 3 qubits quantum subtractor for a = 111, b = 011. Return the QuantumCircuit after measure the result qubits.
""" | QSub | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def QSub(cir = QuantumCircuit(8,3), a = '111', b = '011') ->QuantumCircuit:
def to_twos_complement(binary_str):
n = len(binary_str)
inverted = ''.join('1' if x == '0' else '0' for x in binary_str)
inverted_as_int = int(in... | QUANTUM_ALGO | qiskit | [
0,
0,
0,
0,
1,
0,
0,
0
] |
24 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def W_State_4() ->QuantumCircuit:
"""
Implement a 4 qubits W state quantum circuit. Return the QuantumCircuit after measure all qubits.
""" | W_State_4 | from qiskit import QuantumCircuit
from qiskit.circuit.library import UnitaryGate
import numpy as np
def W_State_4() -> QuantumCircuit:
def RBSGate(theta):
rbs_matrix = np.array([
[1, 0, 0, 0],
[0, np.cos(theta), -np.sin(theta), 0],
[0, np.sin(theta), np... | QUANTUM_ALGO | qiskit | [
0,
0.245,
0.254,
0,
0.231,
0,
0,
0,
0.27,
0,
0,
0,
0,
0,
0,
0
] |
25 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def qpe_grover00_gate(n_count=3) ->QuantumCircuit:
"""
Use Grover’s algorithm to mark state |00⟩, then apply a 3 qubits Quantum Phase Estimation using the Grover oper... | qpe_grover00_gate | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.circuit.library import QFT
def qpe_grover00_gate(n_count=3):
def grover_search_oracle_00() ->QuantumCircuit:
qc = QuantumCircuit(2)
qc.h(0)
qc.h(1)
qc.x(0)
qc.x(1)
qc.h(1)
qc.cx... | QUANTUM_ALGO | qiskit | [
0.767,
0,
0,
0,
0.233,
0,
0,
0
] |
26 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def GHZ3_SWAPTEST() ->QuantumCircuit:
"""
Prepare a 3-qubit GHZ state and compare it with a |+++> state using the SWAP test. Use 3 ancilla qubits and measure ancilla ... | GHZ3_SWAPTEST | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def GHZ3_SWAPTEST() ->QuantumCircuit:
qc = QuantumCircuit(9,3)
qc.h([0,1,2])
qc.h(3)
qc.cx(3,4)
qc.cx(4,5)
qc.h([6,7,8])
for i in range(3):
qc.cswap(i,i+2,i+5)
qc.h([0,1,2])
qc.measure([0,1,2],[0,1,2])
... | QUANTUM_ALGO | qiskit | [
0.413,
0.096,
0.088,
0.035,
0.156,
0.094,
0.088,
0.03
] |
27 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def decompose_CNOT() ->QuantumCircuit:
"""
Decompose CNOT gate use Hadmard gate and CZ gate. Return the QuantumCircuit without measure.
""" | decompose_CNOT | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def decompose_CNOT() ->QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.h(1)
qc.cz(0,1)
qc.h(1)
qc.measure(0,0)
qc.measure(1,1)
return qc | DECOMPOSITION | qiskit | [
1,
0,
0,
0
] |
28 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def decompose_CCCNOT() ->QuantumCircuit:
"""
Implement a 5 qubits quantum circuit, construct a decomposition of the CCCNOT (triple-controlled NOT) gate using CCNOT ga... | decompose_CCCNOT | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def decompose_CCCNOT() ->QuantumCircuit:
qc = QuantumCircuit(5, 4)
qc.ccx(0, 1, 3)
qc.ccx(2, 3, 4)
qc.ccx(0, 1, 3)
qc.measure([0,1,2,3], [0,1,2,3])
return qc | QUANTUM_ALGO | qiskit | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
29 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
from numpy import pi
def chsh_circuit(alice: int, bob: int)->QuantumCircuit:
"""
Design a CHSH circuit that takes bits of Alice and Bob as input and return the Quantum Circuit after measuring.
""" | chsh_circuit | from qiskit import QuantumCircuit
from numpy import pi
def chsh_circuit(alice: int, bob: int)->QuantumCircuit:
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.barrier()
if alice == 0:
qc.ry(0, 0)
else:
qc.ry(-pi / 2, 0)
qc.measure(0, 0)
if bob == ... | QUANTUM_ALGO | qiskit | [
0.511,
0.489,
0,
0
] |
30 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
def or_circuit()->QuantumCircuit:
"""
Design a or circuit that takes Qubit 0 and Qubit 1 as input and Qubit 3 as result, return the Quantum Circuit after measure Qubit 2.
""" | or_circuit | from qiskit import QuantumCircuit
def or_circuit()->QuantumCircuit:
qc = QuantumCircuit(3,1)
qc.x(0)
qc.x(1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.measure(2, 0)
return qc | QUANTUM_ALGO | qiskit | [
1,
0
] |
31 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
import numpy as np
def period_finding_7_15()->QuantumCircuit:
"""
Design a quantum circuit to solve the Period Finding Problem (with a = 7, N = 15), return the Quantum Circuit after measuring.
""" | period_finding_7_15 | from qiskit import QuantumCircuit
import numpy as np
def period_finding_7_15()->QuantumCircuit:
N = 15
m = int( np.ceil( np.log2( N ) ) )
U_qc = QuantumCircuit(m,m)
U_qc.x( range(m) )
U_qc.swap(1, 2)
U_qc.swap(2, 3)
U_qc.swap(0, 3)
U_qc.measure(range(m),range(m))
return U_qc | QUANTUM_ALGO | qiskit | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] |
32 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
import numpy as np
def shor_7mod15()->QuantumCircuit:
"""
Design a quantum circuit that implentment a shor's algorithm to solve 7 mod 15, Use a 8 qubits for the phase register and 4 qubits for the modular exp... | shor_7mod15 | from qiskit import QuantumCircuit
import numpy as np
from qiskit.circuit.library import QFT
def shor_7mod15()->QuantumCircuit:
N = 15
m = int( np.ceil( np.log2( N ) ) )
phase_register_size = 8
cu_register_size = 4
qc = QuantumCircuit(phase_register_size + cu_register_size, phase_register_size)
q... | QUANTUM_ALGO | qiskit | [
0.261,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... |
33 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def ipe_s_gate() -> QuantumCircuit:
"""
Implement an Iterative Phase Estimation (IPE) circuit to estimate the phase of the S gate, using 2 iterations.
... | ipe_s_gate | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit_aer import AerSimulator
import numpy as np
def ipe_s_gate() -> QuantumCircuit:
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.x(1)
qc.cp(np.pi, 0, 1)
qc.h(0)
... | QUANTUM_ALGO | qiskit | [
0,
1,
0,
0
] |
34 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def ipe_t_gate() -> QuantumCircuit:
"""
Implement an Iterative Phase Estimation (IPE) circuit to estimate the phase of the T gate, using 3 iterations.
... | ipe_t_gate | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
import numpy as np
from qiskit_aer import AerSimulator
def ipe_t_gate() -> QuantumCircuit:
qr = QuantumRegister(2)
cr = ClassicalRegister(3)
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.x(1)
qc.cp(np.pi,0,1)
qc.h(0)
qc.measu... | QUANTUM_ALGO | qiskit | [
0,
1,
0,
0,
0,
0,
0,
0
] |
35 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
def parity_check_3bit() -> QuantumCircuit:
"""
Construct a quantum circuit to check the parity of a 3-qubit input state and return quantum circuit after measure one qubit
""" | parity_check_3bit | from qiskit import QuantumCircuit
def parity_check_3bit() -> QuantumCircuit:
qc = QuantumCircuit(4, 1)
qc.cx(0, 3)
qc.cx(1, 3)
qc.cx(2, 3)
qc.measure(3, 0)
return qc | STATE_PREPARATION | qiskit | [
1,
0
] |
36 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
def reverse_state_preparation_bell() -> QuantumCircuit:
"""
Build a circuit to uncompute the Bell state back to |00>. Return the QuantumCircuit after measurement.
""" | reverse_state_preparation_bell | from qiskit import QuantumCircuit
def reverse_state_preparation_bell() -> QuantumCircuit:
qc = QuantumCircuit(2, 2)
qc.cx(0, 1)
qc.h(0)
qc.measure(0, 0)
qc.measure(1, 1)
return qc | STATE_PREPARATION | qiskit | [
0.497,
0.503,
0,
0
] |
37 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
import numpy as np
def controlled_hadamard() -> QuantumCircuit:
"""
Decompose a controlled-Hadamard gate using basic gates. Return the QuantumCircuit after measure.
""" | controlled_hadamard | from qiskit import QuantumCircuit
import numpy as np
def controlled_hadamard() -> QuantumCircuit:
qc = QuantumCircuit(2, 2)
qc.ry(np.pi/4, 1)
qc.cx(0, 1)
qc.ry(-np.pi/4, 1)
qc.measure(0, 0)
qc.measure(1, 1)
return qc | DECOMPOSITION | qiskit | [
1,
0,
0,
0
] |
39 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
def quantum_state_preparation(parameters: ParameterVector) -> QuantumCircuit:
"""
Prepares a single-qubit variational quantum state based on input parameters. This f... | quantum_state_preparation | from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
from qiskit.quantum_info import SparsePauliOp
def quantum_state_preparation(parameters) -> QuantumCircuit:
circuit = QuantumCircuit(1)
circuit.rx(parameters[0], 0)
circuit.ry(parameters[1], 0)
return circuit | STATE_PREPARATION | qiskit | [
0.514,
0.486
] |
40 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.library import U3Gate
from qiskit.circuit import ParameterVector
import numpy as np
def VQE_2(parameters) -> QuantumCircuit:
"""
Prepares a double-qubit var... | VQE_2 | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.library import U3Gate
from qiskit.circuit import ParameterVector
import numpy as np
def VQE_2(parameters: ParameterVector) -> QuantumCircuit:
qr = QuantumRegister(2)
circuit = QuantumCircuit(qr)
circuit.append(U3Gate(n... | STATE_PREPARATION | qiskit | [
0.218,
0.214,
0.247,
0.321
] |
41 | I need you to complete the following code. No explanation needed.
import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit_aer.primitives import Estimator
from qiskit.primitives import StatevectorSampler as Sampler
from qiskit.quantum_info import SparsePauliOp
from scipy.optimize import minimize
def VQ... | VQE_Z2 | from qiskit import QuantumCircuit
def VQE_Z2(param):
qc = QuantumCircuit(2, 2)
qc.u(param[0], param[1], param[2], 0)
qc.u(param[3], param[4], param[5], 1)
return qc | STATE_PREPARATION | qiskit | [
0.314,
0.232,
0.266,
0.188
] |
42 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
import numpy as np
def U_gate_decompose(theta, phi, lam) -> QuantumCircuit:
"""
Decompose U gate into a sequence of RZ and SX gates, ignore the goble phase, return the quantum circuit without measure.
""" | U_gate_decompose | from qiskit import QuantumCircuit
import numpy as np
def U_gate_decompose(theta, phi, lam) -> QuantumCircuit:
qc = QuantumCircuit(1)
qc.rz(lam, 0)
qc.sx(0)
qc.rz(theta + np.pi, 0)
qc.sx(0)
qc.rz(phi + 3*np.pi, 0)
return qc | DECOMPOSITION | qiskit | [
0.595,
0.405
] |
43 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
import numpy as np
def Toffoli_gate_decompose() -> QuantumCircuit:
"""
Decompose Toffoli gate into a sequence of RZ, SX and CX gates, ignore the goble phase, return the quantum circuit without measure.
""" | Toffoli_gate_decompose | from qiskit import QuantumCircuit
import numpy as np
def Toffoli_gate_decompose() -> QuantumCircuit:
qc = QuantumCircuit(3)
qc.rz(np.pi/2,2)
qc.sx(2)
qc.rz(np.pi/2,2)
qc.cx(1,2)
qc.rz(-np.pi/4,2)
qc.cx(0,2)
qc.rz(np.pi/4,2)
qc.cx(1,2)
qc.rz(np.pi/4,1)
qc.cx(0,2)
qc.cx(0,1... | DECOMPOSITION | qiskit | [
0.866,
0,
0,
0,
0.134,
0,
0,
0
] |
44 | I need you to complete the following code. No explanation needed.
from qiskit import QuantumCircuit
import numpy as np
def CX_gate_decompose_Clifford() -> QuantumCircuit:
"""
Decompose CX gate into a sequence of local Clifford gates, return the quantum circuit after measure all qubits.
""" | CX_gate_decompose_Clifford | from qiskit import QuantumCircuit
import numpy as np
def CX_gate_decompose_Clifford() -> QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.sdg(0)
qc.s(1)
qc.h(1)
qc.s(1)
qc.ecr(0, 1)
qc.x(0)
qc.measure([0,1],[0,1])
return qc | DECOMPOSITION | qiskit | [
1,
0,
0,
0
] |
01 | I need you to complete the following code. No explanation needed.
import cirq
def grover_search_oracle_00() :
"""
Implement a quantum circuit using grover algorithm to find oracle |00> using cirq, return cirq.Circuit after measurement with key='result'.
""" | grover_search_oracle_00 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def grover_search_oracle_00() ->QuantumCircuit:
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h([0, 1])
qc.x([0, 1])
qc.cz(0, 1)
qc.x([0, 1])
qc.h([0, 1])
qc.z([0,... | QUANTUM_ALGO | cirq | [
1,
0,
0,
0
] |
02 | I need you to complete the following code. No explanation needed.
import cirq
def generate_quantum_state_qubit3() :
"""
Implementation a quantum circuit to create the state ψ = √(1/2)(|011⟩ − |100⟩) using cirq, return cirq.Circuit after measurement with key='result'.
""" | generate_quantum_state_qubit3 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit3() -> QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.h(2)
qc.x(1)
qc.cx(2,1)
qc.cx(1,0)
qc.z(2)
qc.measure([0,1,2], [0,1,2])
return qc | STATE_PREPARATION | cirq | [
0,
0,
0,
0.48,
0.52,
0,
0,
0
] |
03 | I need you to complete the following code. No explanation needed.
import cirq
def grover_3SAT() :
"""
Implement a quantum circuit using grover algorithm to solve the 3 SAT problem with 3-CNF formula {((x1) | (x2) | (x3))
& ((_not(x1)) | (x2) | (x3))
& ((_not(x1)... | grover_3SAT | from qiskit.circuit.library import PhaseOracle
from qiskit_algorithms import Grover, AmplificationProblem
from qiskit.primitives import Sampler
def grover_3SAT():
"""
Solve 3-SAT problem using Grover's Algorithm (compatible with new Qiskit version).
Formula:
((x1) ∨ (x2) ∨ (x3)) ∧
(¬x1 ∨ x2 ∨ x3) ∧... | QUANTUM_ALGO | cirq | [
0,
0,
0.5028,
0,
0,
0,
0.4972,
0
] |
04 | I need you to complete the following code. No explanation needed.
import cirq
def qaoa_maxcut_ansatz(G=None, beta=None, gamma=None) :
"""
Implement a quantum circuit using QAOA algorithm to solve the maxcut problem with the graph ([[0,3],[0,4],[1,3],[1,4],[2,3],[2,4]]), return cirq.Circuit aft... | qaoa_maxcut_ansatz | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def qaoa_maxcut_ansatz(G, beta, gamma) -> QuantumCircuit:
n = len(G.nodes)
p = len(beta)
qr = QuantumRegister(n, 'q')
cr = ClassicalRegister(n, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(qr)
for i in range(p):
... | QUANTUM_ALGO | cirq | [
0.173,
0.022,
0.025,
0.009,
0.019,
0.002,
0.003,
0,
0.041,
0.032,
0.035,
0.03,
0.02,
0.027,
0.032,
0.051,
0.04,
0.035,
0.017,
0.04,
0.03,
0.028,
0.031,
0.028,
0,
0.004,
0.007,
0.024,
0.002,
0.024,
0.03,
0.139
] |
06 | I need you to complete the following code. No explanation needed.
import cirq
def swaptest_zaxis(unknown_state=None) :
"""
Implement a quantum circuit using the SWAP test algorithm to estimate the angle θ (in radians) between an unknown single-qubit quantum state and the |0⟩ state (Z-axis).
... | swaptest_zaxis | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_zaxis(unknown_state: QuantumCircuit) ->QuantumCircuit:
qr = QuantumRegister(3, 'q')
cr = ClassicalRegister(1, 'c')
qc = QuantumCircuit(qr, cr)
qc = qc.compose(unknown_state, [qr[1]])
qc.h(qr[0])
qc.csw... | QUANTUM_ALGO | cirq | [
0.739,
0.261
] |
07 | I need you to complete the following code. No explanation needed.
import cirq
def swaptest_individual() :
"""
Implement a quantum circuit using the SWAP test with individual ancilla qubits for each qubit-to-qubit comparison between two 3-qubit quantum states: |011⟩ and |000⟩.
Encode |011⟩ on t... | swaptest_individual | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_individual() ->QuantumCircuit:
qr = QuantumRegister(9, 'q')
cr = ClassicalRegister(3, 'c')
qc = QuantumCircuit(qr, cr)
qc.x(qr[1])
qc.x(qr[2])
qc.h(qr[6])
qc.h(qr[7])
qc.h(qr[8])
qc.cswap(qr[6],... | QUANTUM_ALGO | cirq | [
0.248,
0,
0.237,
0,
0.258,
0,
0.257,
0
] |
08 | I need you to complete the following code. No explanation needed.
import cirq
from math import pi
def qft_6() :
"""
Implement a 6 qubit quantum fourier transform circuit, and return cirq.Circuit after measurement with key='result'.
""" | qft_6 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from math import pi
def qft_6():
"""QFT on 6 qubits"""
qr = QuantumRegister(6, 'q')
cr = ClassicalRegister(6, 'c')
qc = QuantumCircuit(qr,cr)
for i in range(5, -1, -1):
qc.h(qr[i])
for j in range(i):
q... | QUANTUM_ALGO | cirq | [
0.02,
0.016,
0.013,
0.012,
0.019,
0.013,
0.012,
0.017,
0.009,
0.02,
0.016,
0.024,
0.009,
0.02,
0.016,
0.012,
0.008,
0.013,
0.009,
0.02,
0.012,
0.017,
0.014,
0.02,
0.016,
0.019,
0.011,
0.013,
0.017,
0.013,
0.017,
0.016,
0.012,
0.017,
0.016,
0.022,... |
09 | I need you to complete the following code. No explanation needed.
import cirq
def qpe_x_gate() :
"""
Implement a quantum circuit to perform Quantum Phase Estimation using 3 counting qubits and 1 target qubit to estimate the phase of a unitary operator X (Pauli-X gate).
return cirq.Circuit afte... | qpe_x_gate | from qiskit import QuantumCircuit
from qiskit.circuit.library import QFT
def qpe_x_gate(n_count=3):
qc = QuantumCircuit(n_count + 1, n_count)
qc.h(range(n_count))
qc.x(n_count)
for qubit in range(n_count):
repetitions = 2**qubit
for _ in range(repetitions):
qc.cx(qubit, n_c... | QUANTUM_ALGO | cirq | [
0.542,
0,
0,
0,
0.458,
0,
0,
0
] |
10 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
from scipy.linalg import expm
import math
def HHL_4x4() :
"""
Implement a quantum circuit that uses the Harrow-Hassidim-Lloyd (HHL) algorithm to solve a linear system Ax = b,
where:
A = (1... | HHL_4x4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
from qiskit.quantum_info import Statevector
from scipy.linalg import expm
from qiskit.circuit.library import UnitaryGate
from qiskit.circuit.library import QFT
from qiskit.circuit.library import RYGate
import math
def HHL_4x4() ->... | QUANTUM_ALGO | cirq | [
0.396,
0.475,
0,
0.129
] |
11 | I need you to complete the following code. No explanation needed.
import cirq
def Deutsch_Jozsa_Balance_4() :
"""
Implement a quantum circuit use DeutschJozsa algorithm to solve a oracle with bitstring "1100", return cirq.Circuit after measurement with key='result'.
""" | Deutsch_Jozsa_Balance_4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def Deutsch_Jozsa_Balance_4() -> QuantumCircuit:
def dj_oracle(case, n):
oracle_qc = QuantumCircuit(n+1)
if case == "balanced":
b = np.random.randint(1,2**n)
b_str = '1100'
... | QUANTUM_ALGO | cirq | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] |
12 | I need you to complete the following code. No explanation needed.
import cirq
def Deutsch_Jozsa_Constant_4() :
"""
Implement a quantum circuit use DeutschJozsa algorithm to solve a oracle with bitstring "0000", return cirq.Circuit after measurement with key='result'.
""" | Deutsch_Jozsa_Constant_4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def Deutsch_Jozsa_Constant_4() -> QuantumCircuit:
def dj_oracle(case, n):
oracle_qc = QuantumCircuit(n+1)
if case == "balanced":
b = np.random.randint(1,2**n)
b_str = '1100'
... | QUANTUM_ALGO | cirq | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
13 | I need you to complete the following code. No explanation needed.
import cirq
def Simon_11() :
"""
Implement a quantum circuit using Simon's algorithm for the case where:
- The input bit length n = 2
- The hidden string s = '11'
return cirq.Circuit after measurement with key... | Simon_11 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_11() ->QuantumCircuit:
qc = QuantumCircuit(4,2)
qc.h(0)
qc.h(1)
for i in range(2):
qc.cx(i,2)
qc.cx(i,3)
qc.h(i)
qc.measure(2,0)
qc.measure(3,1)
return qc | QUANTUM_ALGO | cirq | [
0.503,
0,
0,
0.497
] |
14 | I need you to complete the following code. No explanation needed.
import cirq
def Simon_110() :
"""
Implement a quantum circuit using Simon's algorithm for the case:
- The input bit length n = 3
- The hidden string s = '110'
return cirq.Circuit after measurement with key='re... | Simon_110 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_110() ->QuantumCircuit:
qc = QuantumCircuit(6,3)
for i in range(3):
qc.h(i)
for i in range(3):
qc.cx(i,i+3)
qc.cx(1,4)
qc.cx(1,5)
for i in range(3):
qc.h(i)
qc.measure(i,i)
retur... | QUANTUM_ALGO | cirq | [
0.271,
0.239,
0,
0,
0,
0,
0.244,
0.246
] |
15 | I need you to complete the following code. No explanation needed.
import cirq
def Hadmard_Test_h() :
"""
Implement a 2 qubit Hadmard test quantum circuit for |+> state, return cirq.Circuit after measurement with key='result'.
""" | Hadmard_Test_h | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Hadmard_Test_h() ->QuantumCircuit:
qc = QuantumCircuit(2,1)
qc.h(0)
qc.h(1)
qc.ch(0,1)
qc.h(0)
qc.measure(0,0)
return qc | QUANTUM_ALGO | cirq | [
0.847,
0.153
] |
16 | I need you to complete the following code. No explanation needed.
import cirq
def Bell_State() :
"""
Implement a quantum circuit with Bell State, return cirq.Circuit after measurement with key='result'.
""" | Bell_State | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bell_State() ->QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.h(0)
qc.cx(0,1)
qc.measure(0,0)
qc.measure(1,1)
return qc | QUANTUM_ALGO | cirq | [
0.5,
0,
0,
0.5
] |
17 | I need you to complete the following code. No explanation needed.
import cirq
def GHZ() :
"""
Implement a 3 qubits GHZ state quantum circuit, return cirq.Circuit after measurement with key='result'.
""" | GHZ | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def GHZ() ->QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.h(0)
qc.cx(0,1)
qc.cx(1,2)
qc.measure([0,1,2],[0,1,2])
return qc | QUANTUM_ALGO | cirq | [
0.493,
0,
0,
0,
0,
0,
0,
0.507
] |
18 | I need you to complete the following code. No explanation needed.
import cirq
from numpy import pi
def Quantum_Teleportation() :
"""
Implement a 3 qubits Quantum_Teleportation, Alice own Qubit 0 and Qubit 1, Bob own Qubit2. Alice's initial state is rotated by angle pi/2 around the X axis.
return c... | Quantum_Teleportation | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from numpy import pi
def Quantum_Teleportation() ->QuantumCircuit:
qc = QuantumCircuit(3,1)
qc.rx(pi/2,0)
qc.h(1)
qc.cx(1,2)
qc.cx(0,1)
qc.h(0)
qc.cx(1,2)
qc.cz(0,2)
qc.measure(2,0)
return qc | QUANTUM_ALGO | cirq | [
0.462,
0.538
] |
19 | I need you to complete the following code. No explanation needed.
import cirq
def generate_quantum_state_qubit5() :
"""
implementation a quantum circuit to create the state ψ = √(1/2)(|00110⟩ + |00101⟩) using cirq, return cirq.Circuit after measurement with key='result'.
""" | generate_quantum_state_qubit5 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit5() ->QuantumCircuit:
qc = QuantumCircuit(5,5)
qc.x(2)
qc.h(3)
qc.cx(3,4)
qc.x(4)
qc.measure([0,1,2,3,4],[4,3,2,1,0])
return qc | QUANTUM_ALGO | cirq | [
0,
0,
0,
0,
0,
0.496,
0.504,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
20 | I need you to complete the following code. No explanation needed.
import cirq
def Bernstein_Vazirani_011() :
"""
Implement the Bernstein–Vazirani algorithm for a 3-bit hidden string a = '011'.
return cirq.Circuit after measurement with key='result'.
""" | Bernstein_Vazirani_011 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bernstein_Vazirani_011() ->QuantumCircuit:
qc = QuantumCircuit(4,3)
qc.x(3)
qc.h([0,1,2,3])
qc.cx(1,3)
qc.cx(2,3)
qc.h([0,1,2])
qc.measure([0,1,2],[0,1,2])
return qc | QUANTUM_ALGO | cirq | [
0,
0,
0,
0,
0,
0,
1,
0
] |
21 | I need you to complete the following code. No explanation needed.
import cirq
def MAJ_3() :
"""
Implement a 3-input quantum Majority (MAJ) gate using CNOT and CCNOT (Toffoli) gates.
The circuit takes as input three qubits:
- c_i: the carry bit from the previous stage
- b_i:... | MAJ_3 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def MAJ_3() ->QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.cx(0, 1)
qc.cx(0, 2)
qc.ccx(1, 2, 0)
qc.measure([0, 1, 2], [0, 1, 2])
return qc | QUANTUM_ALGO | cirq | [
1,
0,
0,
0,
0,
0,
0,
0
] |
22 | I need you to complete the following code. No explanation needed.
import cirq
def Qadd() :
"""
Implement a quantum Adder for a = 100, b = 001, and c0 = 1. return cirq.Circuit after measurement with key='result' of the result qubits (4 qubits).
""" | Qadd | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def Qadd() -> QuantumCircuit:
qc = QuantumCircuit(8, 4)
qc.x(0)
qc.x(1)
qc.x(6)
def MAJ(qc,ci,bi,ai):
qc.cx(ai,bi)
qc.cx(ai,ci)
qc.ccx(bi,ci,ai)
return qc
def UMA(qc, ci, bi, ai):
qc.cc... | QUANTUM_ALGO | cirq | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
23 | I need you to complete the following code. No explanation needed.
import cirq
def QSub() :
"""
Implement a 3 qubits quantum subtractor for a = 111, b = 011. return cirq.Circuit after measurement with key='result' of the result qubits.
""" | QSub | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def QSub(cir = QuantumCircuit(8,3), a = '111', b = '011') ->QuantumCircuit:
def to_twos_complement(binary_str):
n = len(binary_str)
inverted = ''.join('1' if x == '0' else '0' for x in binary_str)
inverted_as_int = int(in... | QUANTUM_ALGO | cirq | [
0,
0,
0,
0,
1,
0,
0,
0
] |
24 | I need you to complete the following code. No explanation needed.
import cirq
def W_State_4() :
"""
Implement a 4 qubits W state quantum circuit. return cirq.Circuit after measurement with key='result'.
""" | W_State_4 | from qiskit import QuantumCircuit
from qiskit.circuit.library import UnitaryGate
import numpy as np
def W_State_4() -> QuantumCircuit:
def RBSGate(theta):
rbs_matrix = np.array([
[1, 0, 0, 0],
[0, np.cos(theta), -np.sin(theta), 0],
[0, np.sin(theta), np... | QUANTUM_ALGO | cirq | [
0,
0.245,
0.254,
0,
0.231,
0,
0,
0,
0.27,
0,
0,
0,
0,
0,
0,
0
] |
25 | I need you to complete the following code. No explanation needed.
import cirq
def qpe_grover00_gate(n_count=3) :
"""
Use Grover’s algorithm to mark state |00⟩, then apply a 3 qubits Quantum Phase Estimation using the Grover operator as the unitary.
return cirq.Circuit after measure on first 3 ... | qpe_grover00_gate | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.circuit.library import QFT
def qpe_grover00_gate(n_count=3):
def grover_search_oracle_00() ->QuantumCircuit:
qc = QuantumCircuit(2)
qc.h(0)
qc.h(1)
qc.x(0)
qc.x(1)
qc.h(1)
qc.cx... | QUANTUM_ALGO | cirq | [
0.767,
0,
0,
0,
0.233,
0,
0,
0
] |
26 | I need you to complete the following code. No explanation needed.
import cirq
def GHZ3_SWAPTEST() :
"""
Prepare a 3-qubit GHZ state and compare it with a |+++> state using the SWAP test. Use 3 ancilla qubits and measure ancilla qubits, return cirq.Circuit after measurement with key='result'.
""" | GHZ3_SWAPTEST | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def GHZ3_SWAPTEST() ->QuantumCircuit:
qc = QuantumCircuit(9,3)
qc.h([0,1,2])
qc.h(3)
qc.cx(3,4)
qc.cx(4,5)
qc.h([6,7,8])
for i in range(3):
qc.cswap(i,i+2,i+5)
qc.h([0,1,2])
qc.measure([0,1,2],[0,1,2])
... | QUANTUM_ALGO | cirq | [
0.413,
0.096,
0.088,
0.035,
0.156,
0.094,
0.088,
0.03
] |
27 | I need you to complete the following code. No explanation needed.
import cirq
def decompose_CNOT() :
"""
Decompose CNOT gate use Hadmard gate and CZ gate. return cirq.Circuit after measurement with key='result'.
""" | decompose_CNOT | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def decompose_CNOT() ->QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.h(1)
qc.cz(0,1)
qc.h(1)
qc.measure(0,0)
qc.measure(1,1)
return qc | DECOMPOSITION | cirq | [
1,
0,
0,
0
] |
28 | I need you to complete the following code. No explanation needed.
import cirq
def decompose_CCCNOT() :
"""
Implement a 5 qubits quantum circuit, construct a decomposition of the CCCNOT (triple-controlled NOT) gate using CCNOT gate. qubit0, qubit1, and qubit2 act as control qubits, qubit 3 is ancilla q... | decompose_CCCNOT | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def decompose_CCCNOT() ->QuantumCircuit:
qc = QuantumCircuit(5, 4)
qc.ccx(0, 1, 3)
qc.ccx(2, 3, 4)
qc.ccx(0, 1, 3)
qc.measure([0,1,2,3], [0,1,2,3])
return qc | QUANTUM_ALGO | cirq | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
29 | I need you to complete the following code. No explanation needed.
import cirq
from numpy import pi
def chsh_circuit(alice=None, bob=None):
"""
Design a CHSH circuit that takes bits of Alice and Bob as input and return cirq.Circuit after measurement with key='result'.
""" | chsh_circuit | from qiskit import QuantumCircuit
from numpy import pi
def chsh_circuit(alice: int, bob: int)->QuantumCircuit:
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.barrier()
if alice == 0:
qc.ry(0, 0)
else:
qc.ry(-pi / 2, 0)
qc.measure(0, 0)
if bob == ... | QUANTUM_ALGO | cirq | [
0.511,
0.489,
0,
0
] |
30 | I need you to complete the following code. No explanation needed.
import cirq
def or_circuit():
"""
Design a or circuit that takes Qubit 0 and Qubit 1 as input and Qubit 3 as result, return cirq.Circuit after measurement with key='result'.
""" | or_circuit | from qiskit import QuantumCircuit
def or_circuit()->QuantumCircuit:
qc = QuantumCircuit(3,1)
qc.x(0)
qc.x(1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.measure(2, 0)
return qc | QUANTUM_ALGO | cirq | [
1,
0
] |
31 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def period_finding_7_15():
"""
Design a quantum circuit to solve the Period Finding Problem (with a = 7, N = 15), return cirq.Circuit after measurement with key='result'.
""" | period_finding_7_15 | from qiskit import QuantumCircuit
import numpy as np
def period_finding_7_15()->QuantumCircuit:
N = 15
m = int( np.ceil( np.log2( N ) ) )
U_qc = QuantumCircuit(m,m)
U_qc.x( range(m) )
U_qc.swap(1, 2)
U_qc.swap(2, 3)
U_qc.swap(0, 3)
U_qc.measure(range(m),range(m))
return U_qc | QUANTUM_ALGO | cirq | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] |
32 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def shor_7mod15():
"""
Design a quantum circuit that implentment a shor's algorithm to solve 7 mod 15, Use a 8 qubits for the phase register and 4 qubits for the modular exponentiation.
return cirq.Circu... | shor_7mod15 | from qiskit import QuantumCircuit
import numpy as np
from qiskit.circuit.library import QFT
def shor_7mod15()->QuantumCircuit:
N = 15
m = int( np.ceil( np.log2( N ) ) )
phase_register_size = 8
cu_register_size = 4
qc = QuantumCircuit(phase_register_size + cu_register_size, phase_register_size)
q... | QUANTUM_ALGO | cirq | [
0.261,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... |
33 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def ipe_s_gate() :
"""
Implement an Iterative Phase Estimation (IPE) circuit to estimate the phase of the S gate, using 2 iterations.
return cirq.Circuit after measurement with key='result'.
""" | ipe_s_gate | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit_aer import AerSimulator
import numpy as np
def ipe_s_gate() -> QuantumCircuit:
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.x(1)
qc.cp(np.pi, 0, 1)
qc.h(0)
... | QUANTUM_ALGO | cirq | [
0,
1,
0,
0
] |
34 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def ipe_t_gate() :
"""
Implement an Iterative Phase Estimation (IPE) circuit to estimate the phase of the T gate, using 3 iterations.
return cirq.Circuit after measurement with key='result'.
""" | ipe_t_gate | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
import numpy as np
from qiskit_aer import AerSimulator
def ipe_t_gate() -> QuantumCircuit:
qr = QuantumRegister(2)
cr = ClassicalRegister(3)
qc = QuantumCircuit(qr, cr)
qc.h(0)
qc.x(1)
qc.cp(np.pi,0,1)
qc.h(0)
qc.measu... | QUANTUM_ALGO | cirq | [
0,
1,
0,
0,
0,
0,
0,
0
] |
35 | I need you to complete the following code. No explanation needed.
import cirq
def parity_check_3bit() :
"""
Construct a quantum circuit to check the parity of a 3-qubit input state and return cirq.Circuit after measurement with key='result'
""" | parity_check_3bit | from qiskit import QuantumCircuit
def parity_check_3bit() -> QuantumCircuit:
qc = QuantumCircuit(4, 1)
qc.cx(0, 3)
qc.cx(1, 3)
qc.cx(2, 3)
qc.measure(3, 0)
return qc | STATE_PREPARATION | cirq | [
1,
0
] |
36 | I need you to complete the following code. No explanation needed.
import cirq
def reverse_state_preparation_bell() :
"""
Build a circuit to uncompute the Bell state back to |00>. return cirq.Circuit after measurement with key='result'.
""" | reverse_state_preparation_bell | from qiskit import QuantumCircuit
def reverse_state_preparation_bell() -> QuantumCircuit:
qc = QuantumCircuit(2, 2)
qc.cx(0, 1)
qc.h(0)
qc.measure(0, 0)
qc.measure(1, 1)
return qc | STATE_PREPARATION | cirq | [
0.497,
0.503,
0,
0
] |
37 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def controlled_hadamard() :
"""
Decompose a controlled-Hadamard gate using basic gates. return cirq.Circuit after measurement with key='result'.
""" | controlled_hadamard | from qiskit import QuantumCircuit
import numpy as np
def controlled_hadamard() -> QuantumCircuit:
qc = QuantumCircuit(2, 2)
qc.ry(np.pi/4, 1)
qc.cx(0, 1)
qc.ry(-np.pi/4, 1)
qc.measure(0, 0)
qc.measure(1, 1)
return qc | DECOMPOSITION | cirq | [
1,
0,
0,
0
] |
39 | I need you to complete the following code. No explanation needed.
import cirq
def quantum_state_preparation(parameters=None) :
"""
Prepares a single-qubit variational quantum state based on input parameters. This function constructs a parameterized ansatz circuit consisting of RX and RY rotationson a single... | quantum_state_preparation | from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
from qiskit.quantum_info import SparsePauliOp
def quantum_state_preparation(parameters) -> QuantumCircuit:
circuit = QuantumCircuit(1)
circuit.rx(parameters[0], 0)
circuit.ry(parameters[1], 0)
return circuit | STATE_PREPARATION | cirq | [
0.514,
0.486
] |
40 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def VQE_2(parameters=None) :
"""
Prepares a double-qubit variational quantum state based on input parameters. This function constructs a parameterized ansatz circuit to find the eigenvalue of the observable.
Arg... | VQE_2 | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.library import U3Gate
from qiskit.circuit import ParameterVector
import numpy as np
def VQE_2(parameters: ParameterVector) -> QuantumCircuit:
qr = QuantumRegister(2)
circuit = QuantumCircuit(qr)
circuit.append(U3Gate(n... | STATE_PREPARATION | cirq | [
0.218,
0.214,
0.247,
0.321
] |
41 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
from scipy.optimize import minimize
def VQE_Z2(param):
"""
Implement a quantum circuit compute the minimum eigenvalue of the Z2 Hamiltonian using the Variational Quantum Eigensolver (VQE) algorithm, where param is ... | VQE_Z2 | from qiskit import QuantumCircuit
def VQE_Z2(param):
qc = QuantumCircuit(2, 2)
qc.u(param[0], param[1], param[2], 0)
qc.u(param[3], param[4], param[5], 1)
return qc | STATE_PREPARATION | cirq | [
0.314,
0.232,
0.266,
0.188
] |
42 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def U_gate_decompose(theta=None, phi=None, lam=None) :
"""
Decompose U gate into a sequence of RZ and SX gates, ignore the goble phase, return cirq.Circuit after measurement with key='result'.
""" | U_gate_decompose | from qiskit import QuantumCircuit
import numpy as np
def U_gate_decompose(theta, phi, lam) -> QuantumCircuit:
qc = QuantumCircuit(1)
qc.rz(lam, 0)
qc.sx(0)
qc.rz(theta + np.pi, 0)
qc.sx(0)
qc.rz(phi + 3*np.pi, 0)
return qc | DECOMPOSITION | cirq | [
0.595,
0.405
] |
43 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def Toffoli_gate_decompose() :
"""
Decompose Toffoli gate into a sequence of RZ, SX and CX gates, ignore the goble phase, return cirq.Circuit after measurement with key='result'.
""" | Toffoli_gate_decompose | from qiskit import QuantumCircuit
import numpy as np
def Toffoli_gate_decompose() -> QuantumCircuit:
qc = QuantumCircuit(3)
qc.rz(np.pi/2,2)
qc.sx(2)
qc.rz(np.pi/2,2)
qc.cx(1,2)
qc.rz(-np.pi/4,2)
qc.cx(0,2)
qc.rz(np.pi/4,2)
qc.cx(1,2)
qc.rz(np.pi/4,1)
qc.cx(0,2)
qc.cx(0,1... | DECOMPOSITION | cirq | [
0.866,
0,
0,
0,
0.134,
0,
0,
0
] |
44 | I need you to complete the following code. No explanation needed.
import cirq
import numpy as np
def CX_gate_decompose_Clifford() :
"""
Decompose CX gate into a sequence of local Clifford gates, return cirq.Circuit after measurement with key='result'.
""" | CX_gate_decompose_Clifford | from qiskit import QuantumCircuit
import numpy as np
def CX_gate_decompose_Clifford() -> QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.sdg(0)
qc.s(1)
qc.h(1)
qc.s(1)
qc.ecr(0, 1)
qc.x(0)
qc.measure([0,1],[0,1])
return qc | DECOMPOSITION | cirq | [
1,
0,
0,
0
] |
01 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def grover_search_oracle_00() :
"""
Implement a quantum circuit using grover algorithm to find oracle |00> using pennylane, return qml.sample() with number of shots = 1000.
""" | grover_search_oracle_00 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def grover_search_oracle_00() ->QuantumCircuit:
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
qc = QuantumCircuit(qr, cr)
qc.h([0, 1])
qc.x([0, 1])
qc.cz(0, 1)
qc.x([0, 1])
qc.h([0, 1])
qc.z([0,... | QUANTUM_ALGO | pennylane | [
1,
0,
0,
0
] |
02 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def generate_quantum_state_qubit3() :
"""
Implementation a quantum circuit to create the state ψ = √(1/2)(|011⟩ − |100⟩) using pennylane, return qml.sample() with number of shots = 1000.
""" | generate_quantum_state_qubit3 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def generate_quantum_state_qubit3() -> QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.h(2)
qc.x(1)
qc.cx(2,1)
qc.cx(1,0)
qc.z(2)
qc.measure([0,1,2], [0,1,2])
return qc | STATE_PREPARATION | pennylane | [
0,
0,
0,
0.48,
0.52,
0,
0,
0
] |
03 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def grover_3SAT() :
"""
Implement a quantum circuit using grover algorithm to solve the 3 SAT problem with 3-CNF formula {((x1) | (x2) | (x3))
& ((_not(x1)) | (x2) | (x3))
... | grover_3SAT | from qiskit.circuit.library import PhaseOracle
from qiskit_algorithms import Grover, AmplificationProblem
from qiskit.primitives import Sampler
def grover_3SAT():
"""
Solve 3-SAT problem using Grover's Algorithm (compatible with new Qiskit version).
Formula:
((x1) ∨ (x2) ∨ (x3)) ∧
(¬x1 ∨ x2 ∨ x3) ∧... | QUANTUM_ALGO | pennylane | [
0,
0,
0.5028,
0,
0,
0,
0.4972,
0
] |
04 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def qaoa_maxcut_ansatz(G=None, beta=None, gamma=None) :
"""
Implement a quantum circuit using QAOA algorithm to solve the maxcut problem with the graph ([[0,3],[0,4],[1,3],[1,4],[2,3],[2,4]]), return qml.... | qaoa_maxcut_ansatz | from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def qaoa_maxcut_ansatz(G, beta, gamma) -> QuantumCircuit:
n = len(G.nodes)
p = len(beta)
qr = QuantumRegister(n, 'q')
cr = ClassicalRegister(n, 'c')
qc = QuantumCircuit(qr, cr)
qc.h(qr)
for i in range(p):
... | QUANTUM_ALGO | pennylane | [
0.173,
0.022,
0.025,
0.009,
0.019,
0.002,
0.003,
0,
0.041,
0.032,
0.035,
0.03,
0.02,
0.027,
0.032,
0.051,
0.04,
0.035,
0.017,
0.04,
0.03,
0.028,
0.031,
0.028,
0,
0.004,
0.007,
0.024,
0.002,
0.024,
0.03,
0.139
] |
06 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def swaptest_zaxis(unknown_state) :
"""
Implement a quantum circuit using the SWAP test algorithm to estimate the angle θ (in radians) between an unknown single-qubit quantum state and the |0⟩ state (Z-axis).
... | swaptest_zaxis | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_zaxis(unknown_state: QuantumCircuit) ->QuantumCircuit:
qr = QuantumRegister(3, 'q')
cr = ClassicalRegister(1, 'c')
qc = QuantumCircuit(qr, cr)
qc = qc.compose(unknown_state, [qr[1]])
qc.h(qr[0])
qc.csw... | QUANTUM_ALGO | pennylane | [
0.739,
0.261
] |
07 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def swaptest_individual() :
"""
Implement a quantum circuit using the SWAP test with individual ancilla qubits for each qubit-to-qubit comparison between two 3-qubit quantum states: |011⟩ and |000⟩.
Encod... | swaptest_individual | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
def swaptest_individual() ->QuantumCircuit:
qr = QuantumRegister(9, 'q')
cr = ClassicalRegister(3, 'c')
qc = QuantumCircuit(qr, cr)
qc.x(qr[1])
qc.x(qr[2])
qc.h(qr[6])
qc.h(qr[7])
qc.h(qr[8])
qc.cswap(qr[6],... | QUANTUM_ALGO | pennylane | [
0.248,
0,
0.237,
0,
0.258,
0,
0.257,
0
] |
08 | I need you to complete the following code. No explanation needed.
import pennylane as qml
from math import pi
def qft_6() :
"""
Implement a 6 qubit quantum fourier transform circuit, and return qml.sample() with number of shots = 1000.
""" | qft_6 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from math import pi
def qft_6():
"""QFT on 6 qubits"""
qr = QuantumRegister(6, 'q')
cr = ClassicalRegister(6, 'c')
qc = QuantumCircuit(qr,cr)
for i in range(5, -1, -1):
qc.h(qr[i])
for j in range(i):
q... | QUANTUM_ALGO | pennylane | [
0.02,
0.016,
0.013,
0.012,
0.019,
0.013,
0.012,
0.017,
0.009,
0.02,
0.016,
0.024,
0.009,
0.02,
0.016,
0.012,
0.008,
0.013,
0.009,
0.02,
0.012,
0.017,
0.014,
0.02,
0.016,
0.019,
0.011,
0.013,
0.017,
0.013,
0.017,
0.016,
0.012,
0.017,
0.016,
0.022,... |
09 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def qpe_x_gate() :
"""
Implement a quantum circuit to perform Quantum Phase Estimation using 3 counting qubits and 1 target qubit to estimate the phase of a unitary operator X (Pauli-X gate).
return qml.s... | qpe_x_gate | from qiskit import QuantumCircuit
from qiskit.circuit.library import QFT
def qpe_x_gate(n_count=3):
qc = QuantumCircuit(n_count + 1, n_count)
qc.h(range(n_count))
qc.x(n_count)
for qubit in range(n_count):
repetitions = 2**qubit
for _ in range(repetitions):
qc.cx(qubit, n_c... | QUANTUM_ALGO | pennylane | [
0.542,
0,
0,
0,
0.458,
0,
0,
0
] |
10 | I need you to complete the following code. No explanation needed.
import pennylane as qml
import numpy as np
from scipy.linalg import expm
import math
def HHL_4x4() :
"""
Implement a quantum circuit that uses the Harrow-Hassidim-Lloyd (HHL) algorithm to solve a linear system Ax = b,
where:
... | HHL_4x4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
from qiskit.quantum_info import Statevector
from scipy.linalg import expm
from qiskit.circuit.library import UnitaryGate
from qiskit.circuit.library import QFT
from qiskit.circuit.library import RYGate
import math
def HHL_4x4() ->... | QUANTUM_ALGO | pennylane | [
0.396,
0.475,
0,
0.129
] |
11 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def Deutsch_Jozsa_Balance_4() :
"""
Implement a quantum circuit use DeutschJozsa algorithm to solve a oracle with bitstring "1100", return qml.sample() with number of shots = 1000.
""" | Deutsch_Jozsa_Balance_4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def Deutsch_Jozsa_Balance_4() -> QuantumCircuit:
def dj_oracle(case, n):
oracle_qc = QuantumCircuit(n+1)
if case == "balanced":
b = np.random.randint(1,2**n)
b_str = '1100'
... | QUANTUM_ALGO | pennylane | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] |
12 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def Deutsch_Jozsa_Constant_4() :
"""
Implement a quantum circuit use DeutschJozsa algorithm to solve a oracle with bitstring "0000", return qml.sample() with number of shots = 1000.
""" | Deutsch_Jozsa_Constant_4 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import numpy as np
def Deutsch_Jozsa_Constant_4() -> QuantumCircuit:
def dj_oracle(case, n):
oracle_qc = QuantumCircuit(n+1)
if case == "balanced":
b = np.random.randint(1,2**n)
b_str = '1100'
... | QUANTUM_ALGO | pennylane | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
13 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def Simon_11() :
"""
Implement a quantum circuit using Simon's algorithm for the case where:
- The input bit length n = 2
- The hidden string s = '11'
return qml.sample() with number of... | Simon_11 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_11() ->QuantumCircuit:
qc = QuantumCircuit(4,2)
qc.h(0)
qc.h(1)
for i in range(2):
qc.cx(i,2)
qc.cx(i,3)
qc.h(i)
qc.measure(2,0)
qc.measure(3,1)
return qc | QUANTUM_ALGO | pennylane | [
0.503,
0,
0,
0.497
] |
14 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def Simon_110() :
"""
Implement a quantum circuit using Simon's algorithm for the case:
- The input bit length n = 3
- The hidden string s = '110'
return qml.sample() with number of sho... | Simon_110 | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Simon_110() ->QuantumCircuit:
qc = QuantumCircuit(6,3)
for i in range(3):
qc.h(i)
for i in range(3):
qc.cx(i,i+3)
qc.cx(1,4)
qc.cx(1,5)
for i in range(3):
qc.h(i)
qc.measure(i,i)
retur... | QUANTUM_ALGO | pennylane | [
0.271,
0.239,
0,
0,
0,
0,
0.244,
0.246
] |
15 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def Hadmard_Test_h() :
"""
Implement a 2 qubit Hadmard test quantum circuit for |+> state, return qml.sample() with number of shots = 1000.
""" | Hadmard_Test_h | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Hadmard_Test_h() ->QuantumCircuit:
qc = QuantumCircuit(2,1)
qc.h(0)
qc.h(1)
qc.ch(0,1)
qc.h(0)
qc.measure(0,0)
return qc | QUANTUM_ALGO | pennylane | [
0.847,
0.153
] |
16 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def Bell_State() :
"""
Implement a quantum circuit with Bell State, return qml.sample() with number of shots = 1000.
""" | Bell_State | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def Bell_State() ->QuantumCircuit:
qc = QuantumCircuit(2,2)
qc.h(0)
qc.cx(0,1)
qc.measure(0,0)
qc.measure(1,1)
return qc | QUANTUM_ALGO | pennylane | [
0.5,
0,
0,
0.5
] |
17 | I need you to complete the following code. No explanation needed.
import pennylane as qml
def GHZ() :
"""
Implement a 3 qubits GHZ state quantum circuit, return qml.sample() with number of shots = 1000.
""" | GHZ | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
def GHZ() ->QuantumCircuit:
qc = QuantumCircuit(3,3)
qc.h(0)
qc.cx(0,1)
qc.cx(1,2)
qc.measure([0,1,2],[0,1,2])
return qc | QUANTUM_ALGO | pennylane | [
0.493,
0,
0,
0,
0,
0,
0,
0.507
] |
QuanBench+ is a unified multi-framework benchmark for evaluating LLM-based quantum code generation across Qiskit, Cirq, and PennyLane.
The benchmark contains aligned quantum programming tasks across three frameworks, together with prompts, entry points, reference implementations, task categories, and canonical outputs used for evaluation.
data/all.jsonl: all examples across Qiskit, Cirq, and PennyLanedata/qiskit.jsonl: Qiskit examplesdata/cirq.jsonl: Cirq examplesdata/pennylane.jsonl: PennyLane examplesdata/canonical_outputs.jsonl: canonical outputs by task IDThe main dataset contains:
task_id: task identifierframework: target framework, one of qiskit, cirq, or pennylanecomplete_prompt: prompt given to the language modelentry_point: function entry point expected from the modelcanonical_solution: reference implementationcategory: task categorycanonical_output: reference output used for evaluationfrom datasets import load_dataset
dataset = load_dataset("Jawadkotaich/quanbench-plus")
print(dataset["train"][0])
QuanBench+: A Unified Multi-Framework Benchmark for LLM-Based Quantum Code Generation
Hugging Face Paper Page: https://huggingface.co/papers/2604.08570