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 gate, which is a fundamental type of quantum gate.
Therefore, we can solve this problem by applying the gate to the qubit:
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 gate can be thought of as a quantum circuit version of the gate in classical circuits. (The gate is sometimes referred to as the gate).