I have this code here to solve " I.14 Multi-qubit gate challenge" of the codebook here .
https://codebook.xanadu.ai/I.14
I could not figure out why state|11> is wrong, any idea
dev = qml.device("default.qubit", wires=3)
# State of first 2 qubits
state = [0, 1]
@qml.qnode(device=dev)
def apply_control_sequence(state):
# Set up initial state of the first two qubits
if state[0] == 1:
qml.PauliX(wires=0)
if state[1] == 1:
qml.PauliX(wires=1)
# Set up initial state of the third qubit - use |->
# so we can see the effect on the output
qml.PauliX(wires=2)
qml.Hadamard(wires=2)
##################
# YOUR CODE HERE #
##################
# IMPLEMENT THE MULTIPLEXER
# IF STATE OF FIRST TWO QUBITS IS 01,
#APPLY X TO THIRD QUBIT
qml.PauliX(wires=0)
qml.Toffoli(wires=[0,1,2])
qml.PauliX(wires=0)
# IF STATE OF FIRST TWO QUBITS IS 10,
#APPLY Z TO THIRD QUBIT
qml.PauliX(wires=1)
qml.Hadamard(2)
qml.Toffoli(wires=[0,1,2])
qml.Hadamard(2)
qml.PauliX(wires=1)
# IF STATE OF FIRST TWO QUBITS IS 11,
#APPLY Y TO THIRD QUBIT
qml.S(2)
qml.Toffoli(wires=[0,1,2])
qml.adjoint(qml.S(2))
return qml.state()
print(apply_control_sequence(state))
I got this error:
Incorrect: your circuit does not have the correct action on |11>.