Editorial
The objective is to prepare a superposition state of the three computational basis states . Note we are treating the leftmost qubit as the least significant.
A superposition state involving a non-power-of-two number of computational basis states can be prepared by using controlled-Hadamard () gates.
First, applying a Hadamard gate to the st qubit effects the transformation
Subsequently applying a controlled-Hadamard gate with the st qubit as the control qubit and the nd as the target qubit effects
Finally, applying a controlled- gate with the st qubit as the target qubit and the nd as the control qubit effects
In this way, a superposition state of the three computational basis states is prepared.
Sample Code
Below is a sample program:
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
qc = QuantumCircuit(2)
qc.h(0)
qc.ch(0, 1)
qc.cx(1, 0)
return qc