B1: Copy Oracle

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 100

Writer: admin

Editorial

The oracle takes single qubit computational basis states xx and yy and outputs y=xyy' = x \oplus y. Its truth table is as follows:

xxyyy=xyy' = x \oplus y
000
101
011
110

Observing the truth table carefully, we see that yy' differs from yy only when x=1x=1. This means effecting yyy \rightarrow y' will flip the bit when xx is "active". Such an operation can be achieved by using a controlled-XX gate 1, with xx as the control bit and yy as the target bit.

Thus, the problem can be solved using the controlled-XX 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

  1. For more information about controlled gates, please refer to the editorial of problem A3.