from qiskit.circuit.library import TwoLocal
from qc_grader.challenges.algorithm_design import grade_problem_2a

# Create a TwoLocal circuit with 3 qubits, using Y-rotations ("ry") and controlled-Z gates ("cz")
reference_operator = TwoLocal(3, "ry", "cz", entanglement="linear", reps=1)

# Define specific parameter values for the reference operator
# We can choose any values we want, for example, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6] for the parameter list
parameters = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]

# Assign the specific parameter values to the reference_operator
reference_operator = reference_operator.assign_parameters(parameters)

# Grade the answer
grade_problem_2a(reference_operator)


from qiskit.circuit.library import TwoLocal
from qc_grader.challenges.algorithm_design import grade_problem_2b

# Use the reference operator from Problem 2a
# Make sure you have defined and assigned the reference_operator as done in Problem 2a
# Create a TwoLocal circuit with 3 qubits, using Y-rotations ("ry") and controlled-Z gates ("cz")
reference_operator = TwoLocal(3, "ry", "cz", entanglement="linear", reps=1)

# Define specific parameter values for the reference operator
# We can choose any values we want, for example, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6] for the parameter list
parameters = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]

# Assign the specific parameter values to the reference_operator
reference_operator = reference_operator.assign_parameters(parameters)

# Define the provided variational_form
variational_form = TwoLocal(3, rotation_blocks=["rx", "rz"], entanglement_blocks="cx")

# Create the ansatz by composing the reference_operator with the variational_form
ansatz = reference_operator.compose(variational_form)

# Grade the answer
grade_problem_2b(reference_operator, variational_form, ansatz)
