A1: Generate State One

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 100

Writer: fortoobye

Editorial

Quantum computers use the concept of "quantum gates" to manipulate the state of qubits.

To flip a bit in the computational basis states of a quantum state, we can use the XX gate, which is a fundamental type of quantum gate.

Therefore, we can solve this problem by applying the XX gate to the qubit:

0X(0)1\begin{equation} \ket{0} \xrightarrow{X(0)} \ket{1} \end{equation}

Sample Code

Below is a sample code:

from qiskit import QuantumCircuit
 
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
 
    # Apply X gate to the 1st qubit (index 0)
    qc.x(0)
 
    return qc

Alternatively, the quantum gate can be applied using a slightly different syntax:

from qiskit import QuantumCircuit
from qiskit.circuit.library import XGate
 
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
 
    qc.append(XGate(), [0])
 
    return qc

Supplements

  • The XX gate can be thought of as a quantum circuit version of the NOT\mathrm{NOT} gate in classical circuits. (The XX gate is sometimes referred to as the NOT\mathrm{NOT} gate).