PennyLane
Next

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

Intermediate
Optimization

Secrets in Spacetime

Challenge statement

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

Zenda needs to send quantum states to Reece over a channel where someone could intercept the messages. They decide to encode the states they want to send with rotations on all of the qubits. To do this, they have chosen two real numbers, \alpha and \beta, in advance, so that the states can be encoded as follows:

Cbit vs cobit

In this case, U(\theta) is defined as the gate that generates the state |{\psi}\rangle — what Zenda wants to send to Reece — that depends on a real number \theta. Thus, if someone intercepts the message, instead of getting state |\psi\rangle they will get state (R_X(\beta)R_Z(\alpha))^{\otimes 2}|\psi\rangle.

Although it seems like a super secure encoding procedure, it is not perfect! Once \alpha and \beta have been chosen, there are certain values of \theta that could make (R_X(\beta)R_Z(\alpha))^{\otimes 2}|\psi\rangle = |\psi\rangle for certain states. This is a big problem — it means that someone is going to intercept the hidden state!

We will say that \alpha and \beta are \epsilon-unsafe values if there exists a \theta such that

|\langle 0|U^{\dagger}(\theta)(R_X(\beta)R_Z(\alpha))^{\otimes 2}U(\theta)|0\rangle|^2 \ge 1 - \epsilon.

Your goal is to determine if \alpha and \beta are unsafe values given \epsilon.

Challenge code

In the code below, you are given a function called is_unsafe. You must complete this function by coming up with a way — you are given total freedom, from making a variational circuit to finding an analytical solution — to determine if the given values of \alpha and \beta values are \epsilon-unsafe.

Inputs

As input to this problem, you are given a list(float) containing the values of \alpha, \beta, and \epsilon, in that order.

Output

This code must output a boolean — True or False — corresponding to whether the values of \alpha and \beta are \epsilon-unsafe. For example, if you determine that the given values of \alpha and \beta aren't \epsilon-unsafe, your code must output False.

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: [0.1, 0.2, 0.3] expected_output: True test_input: [1.1, 1.2, 0.3] expected_output: False test_input: [1.1, 1.2, 0.4] expected_output: True test_input: [0.5, 1.9, 0.7] expected_output: True

If your solution matches the correct one, the output will be "Success!". Otherwise, you will receive an "Incorrect" prompt.

Good luck!

Loading...