Setup step

During the setup step, we put the input qubits, which start out as |"0">, in a superposition by applying the H gate to each of them. This is done with the following code:

for i in range(num_inputs):
qc.h(qr[i])

Recall that H|"0"> = |"+">, so we have put all the input qubits in the plus state. If we have three input qubits over which our checker function will operate, num_qubits in this example would be equal to 3.

We will also put the output of the checker function in the minus state, recalling that HX|"0"> = H|"1"> = |"-">, with the following code: 

# Setting up the output of the checker function
qc.x(qr[num_registers-1])
qc.h(qr[num_registers-1])

We will need many temporary quantum registers to get to the output to store intermediate results. num_registers will be set to the total number of quantum registers needed, the sum of the number of input registers, the register in which the checker output resides, as well as the number of temporary registers needed.