PennyLane
Previous

To attempt this challenge, please switch to a larger screen size.

Advanced
Error Correction

Changing Qubits

Challenge statement

This challenge is included in the QHack 2023 Flashback Badge Challenge event.

This challenge's statement is very simple, but solving it may not be so easy. The goal will be to move a state \vert\psi\rangle from one qubit to another, as shown in the figure:

drawing

Easy, isn't it? Well, we are going to complicate it a little bit. We will not allow any direct connections between the first and last qubits, so you will have to use the middle qubit to pass the information from one qubit to another.

The exercise has become more challenging, but we still want to complicate it further! In addition to all of the above, we are going to generate a virus operator U and place it in the middle of the circuit, like so:

drawing

In this case, U consists of one PauliX gate that we place randomly in one of the three qubits (each time, the gate is generated in a different wire). You should be able to complete the circuit so that, regardless of the randomly generated operator U, you are able to move the state from the first qubit to the last qubit.

Challenge code

In this challenge, you will only be asked to complete the circuit_left and circuit_right operators to meet the objective of the statement.

Input

To encode the initial state \vert \psi \rangle, we will use a U3 gate. The input will be the three parameters (alpha,beta,gamma) associated with this gate.

Output

In this case, the output is the measurement result of the last qubit with respect to an observable. In this way, we check if it coincides with the expected state. Good luck!

Test cases

The following public test cases are available to you. Note that there are additional hidden test cases that we use to verify that your code is valid in full generality.

test_input: [2.0,1.0,3.0] expected_output: -0.97322 test_input: [-0.5,1.2,-1.2] expected_output: 0.88563 test_input: [0.22,3.0,2.1] expected_output: 0.457152 test_input: [2.22,3.1,-3.3] expected_output: -0.335397 test_input: [-0.2,-0.1,3.4] expected_output: 0.470199 test_input: [-1.2,-1.1,0.4] expected_output: -0.6494612

If your solution matches the correct one within the given tolerance specified in check (in this case it's a 1e-4 relative error tolerance), the output will be "Success!". Otherwise, you will receive an "Incorrect" prompt.

Good luck!

Loading...