Jawadkotaich/quanbench-plus huggingface dataset:
import cirq
def Hadmard_Test_h() : 
    """
        Implement a 2 qubit Hadmard test quantum circuit for |+> state, return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
import cirq
def Bell_State() : 
    """
        Implement a quantum circuit with Bell State, return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
import cirq
def GHZ() : 
    """
        Implement a 3 qubits GHZ state quantum circuit, return cirq.Circuit after measurement with key='result'. 
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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 cirq.Circuit after just measure Bob's qubit with key='result'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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'.
        """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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: one of the current bits to add
            - a_i: the other current bit to add
        The MAJ gate performs the following transformations (reversible logic only):
            - Output 1: a_i ⊕ b_i 
            - Output 2: a_i ⊕ c_i 
            - Output 3: c_{i+1}, the carry-out of the majority function over a_i, b_i, and c_i
        return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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).
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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.ccx(bi,ci,ai)
        qc.cx(ai,ci)
        qc.cx(ci,bi)
        return qc
    for i in range(3):
        MAJ(qc,2*i,2*i+1,2*i+2)
    qc.cx(6,7)
    for i in range(2,-1,-1):
        UMA(qc,2*i,2*i+1,2*i+2)
    qc.measure([1,3,5,7],[0,1,2,3])
    return qc
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.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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(inverted, 2) + 1
        twos_complement = bin(inverted_as_int)[-n:]
        if len(twos_complement) < n:
            twos_complement = '0' * (n - len(twos_complement)) + twos_complement
        return twos_complement

    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.ccx(bi,ci,ai)
        qc.cx(ai,ci)
        qc.cx(ci,bi)
        return qc
    
    b=to_twos_complement(b)
    for i,s in enumerate(a[::-1]):
        if s=='1':
            cir.x(2*i+2)
    for i,s in enumerate(b[::-1]):
        if s=='1':
            cir.x(2*i+1)
    l=len(a)
    cir.barrier()
    for i in range(l):
        MAJ(cir,2*i,2*i+1,2*i+2)
        cir.barrier()
    cir.cx(len(a)+len(b),len(a)+len(b)+1)
    for i in range(l-1,-1,-1):
        cir.barrier()
        UMA(cir,2*i,2*i+1,2*i+2)
    cir.measure([1,3,5],[0,1,2])
    return cir

if __name__ == "__main__":
    a='111'
    b='011' 

    qubit_num=len(a)+len(b)+2
    #cir = QuantumCircuit(qubit_num)
    cir = QSub()
    print(cir)
import cirq
def W_State_4() : 
    """
        Implement a 4 qubits W state quantum circuit. return cirq.Circuit after measurement with key='result'. 
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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.cos(theta), 0],
            [0, 0,          0,         1]
        ])
        return UnitaryGate(rbs_matrix, label="RBS")
    
    qc = QuantumCircuit(4,4)    
    qc.x(0)
    qc.append(RBSGate(np.arccos(1/np.sqrt(4))), [0, 1])
    qc.append(RBSGate(np.arccos(1/np.sqrt(3))), [1, 2])
    qc.append(RBSGate(np.arccos(1/np.sqrt(2))), [2, 3])
    qc.measure([0, 1, 2, 3], [0, 1, 2, 3])
    return qc
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 qubits only. with key='result'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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(0,1)
        qc.x(0)
        qc.h(1)
        qc.h(0)
        qc.x(1)
        qc.h(1)
        return qc

    grover_00 = grover_search_oracle_00().to_gate()
    cgrover_00 = grover_00.control(1)
    qc = QuantumCircuit(n_count + 2, n_count)
    qc.h(range(n_count))
    qc.x(range(n_count,n_count+2))

    for qubit in range(n_count):
        repetitions = 2**qubit
        for _ in range(repetitions):
            qc.append(cgrover_00,[qubit, n_count,n_count+1])

    qc.append(QFT(n_count, inverse=True, do_swaps=True).to_gate(), range(n_count))

    qc.measure(range(n_count), range(n_count))

    return qc
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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])
    return qc
import cirq
def decompose_CNOT() : 
    
    """
        Decompose CNOT gate use Hadmard gate and CZ gate. return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: DECOMPOSITION

Solution:
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
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 qubit, and qubit4 is the target qubit.
        return cirq.Circuit after measure control and target qubits with key='result'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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 == 0:       
            qc.ry(-pi / 4, 1)
        else:
            qc.ry(pi / 4, 1)
            qc.measure(1, 1)
    return qc
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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
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.Circuit after measurement with key='result' phase register.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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)
    qc.h(range(8))
    qc.x(8)

    def cU_multi(k):
        U_qc = QuantumCircuit( m )
        U_qc.x( range(m) )
        U_qc.swap(1, 2)
        U_qc.swap(2, 3)
        U_qc.swap(0, 3)
        U = U_qc.to_gate()
        sys_register_size = 4
        circ = QuantumCircuit( sys_register_size )
        for _ in range(2**k):
            circ.append(U, range(sys_register_size))
        U_multi = circ.to_gate()
        U_multi.name = "7Mod15_[2^{}]".format(k)
        cU_multi = U_multi.control()
        return cU_multi
    
    # def apply_qft_inverse(n):
    #     qc = 
    for k in range( phase_register_size ):
        cU = cU_multi(k)
        qc.append( cU, [k] + list( range( phase_register_size,
                                                ( phase_register_size + cu_register_size ) ) ) )

    # for qubit_idx in range( phase_register_size // 2 ):
    #     qc.swap( qubit_idx, ( 8 - qubit_idx - 1 ) )
    qc.append(QFT(phase_register_size).inverse(), range(phase_register_size))
    qc.measure(range( phase_register_size ),range( phase_register_size ))

    return qc
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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)
    qc.measure(0, 0)
    qc.reset(0)
    qc.h(0)
    with qc.if_test((cr[0], True)):
        qc.p( -np.pi / 2, 0 )
    qc.cp(np.pi/2, 0 ,1)
    qc.h(0)
    qc.measure(0, 1)
    return qc

if __name__ == "__main__":
    # 创建一个模拟器
    simulator = AerSimulator()

    # 执行电路并获取结果
    circuit = ipe_s_gate()
    print(circuit)
    result = simulator.run(circuit).result()
    counts = result.get_counts(circuit)

    # 打印结果
    print("Counts:", counts)
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'.
    """

Framework: cirq | Category: QUANTUM_ALGO

Solution:
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.measure(0,0)
    qc.reset(0)
    qc.h(0)
    with qc.if_test( ( cr[0], True ) ): 
        qc.p( -np.pi / 2, 0 )
    qc.cp(np.pi/2,0,1)
    qc.h(0)
    qc.measure(0,1)
    qc.reset(0)
    qc.h(0)
    with qc.if_test( ( cr[0], True ) ): 
        qc.p( -np.pi / 4, 0 )
    qc.cp(np.pi/4,0,1)
    qc.h(0)
    qc.measure(0,2)
    return qc

# if __name__ == "__main__":
#     # 创建一个模拟器
#     simulator = AerSimulator()

#     # 执行电路并获取结果
#     circuit = ipe_t_gate()
#     result = simulator.run(circuit).result()
#     counts = result.get_counts(circuit)

#     # 打印结果
#     print("Counts:", counts)
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'
    """

Framework: cirq | Category: STATE_PREPARATION

Solution:
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
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'.
    """

Framework: cirq | Category: STATE_PREPARATION

Solution:
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
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'.
    """

Framework: cirq | Category: DECOMPOSITION

Solution:
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
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 qubit.
        return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: STATE_PREPARATION

Solution:
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
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.
    Args:
        parameters (list or array-like): A list of 8 real-valued parameters:
            - parameters[0–2]: RZ, RZ, RY rotations on qubit 0
            - parameters[3]:    RZ rotation on qubit 1
            - parameters[4–6]: RZ, RZ, RY on qubit 0
            - parameters[7]:    RZ rotation on qubit 1
    return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: STATE_PREPARATION

Solution:
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(np.pi,0,np.pi) ,[qr[0]])
    circuit.rz(parameters[0], 0)
    circuit.rz(parameters[1], 0)
    circuit.ry(parameters[2], 0)
    circuit.rz(parameters[3], 1)
    circuit.cx(0, 1)
    circuit.rz(parameters[4], 0)
    circuit.rz(parameters[5], 1)
    circuit.ry(parameters[6], 0)
    circuit.rz(parameters[7], 1)
    return circuit
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 an array of angles. 
    return cirq.Circuit after measurement with key='result'.
    """

Framework: cirq | Category: STATE_PREPARATION

Solution:
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
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'.
    """

Framework: cirq | Category: DECOMPOSITION

Solution:
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
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'.
    """

Framework: cirq | Category: DECOMPOSITION

Solution:
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)
    qc.rz(3*np.pi/4,2)
    qc.rz(np.pi/4,0)
    qc.rz(-np.pi/4,1)
    qc.sx(2)
    qc.cx(0,1)
    qc.rz(np.pi/2,2)
    return qc
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'.
    """

Framework: cirq | Category: DECOMPOSITION

Solution:
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
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.
    """

Framework: pennylane | Category: QUANTUM_ALGO

Solution:
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, 1])
    qc.cz(0, 1)
    qc.x([0, 1])
    qc.h([0, 1])
        
    qc.measure([0, 1], [0, 1])
   
    return qc
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.
        """

Framework: pennylane | Category: STATE_PREPARATION

Solution:
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