Editorial
In problem A1, we prepared the "uniform superposition state" on qubit.
Now, how can we express the state of qubits when each of the qubits is in a uniform superposition state?
When measuring one qubit, we observe either of the computational basis states or with equal probability . Therefore, when measuring qubits in sequence, we can observe any one of the possible computational basis states — from to — with equal probabilities of .
Consequently, the state of the uniform superposition state of all computational basis states can be expressed as
As a result, we can prepare a uniform superposition state by applying a Hadamard gate to each of the qubits:
Sample Code
Below is a sample program:
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
qc.h(range(n))
return qcAlternatively, you can use a for-loop to apply the Hadamard gates in turn.
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
for i in range(n):
qc.h(i)
return qc