Editorial
The oracle takes single qubit computational basis states and and outputs . Its truth table is as follows:
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 0 |
Observing the truth table carefully, we see that differs from only when . This means effecting will flip the bit when is "active". Such an operation can be achieved by using a controlled- gate 1, with as the control bit and as the target bit.
Thus, the problem can be solved using the controlled- gate.
Sample Code
Below is a sample program:
from qiskit import QuantumCircuit, QuantumRegister
def solve() -> QuantumCircuit:
x, y = QuantumRegister(1), QuantumRegister(1)
qc = QuantumCircuit(x, y)
qc.cx(x, y)
return qc
Footnotes
-
For more information about controlled gates, please refer to the editorial of problem A3. ↩