# How do you pass input to a circuit? [closed]

I've implemented Grover's search algorithm in qiskit, and I'd like to pass in an input to run through the circuit. How is that done?

• Hey! What do you mean by pass an input in? Grover uses an oracle to search all potential options to find the desired result – met927 Nov 14 '19 at 9:54
• As a follow-on from the above comment, do you mean the input to the circuit (which is generally taken to be all $\left|0\right>$ by default) or are you asking how you create the oracle? Or how you store the data for the oracle? Or something else? It would probably be worth looking up these questions: 1, 2, 3, 4, 5 – Mithrandir24601 Nov 19 '19 at 22:31

It would be helpful to get a code sample, but from how you've phrased the question, the circuit assumes that the register is originally initialized to the $${|00..0\rangle }$$ state. You'll need to initialize the register into the uniform superposition of all states, and then your Grover's algorithm should work.

*full disclosure - it would be super helpful to have more context in your question.

To give you an example, at the last Qiskit Camp I was part of a team that implemented some Groverian Iterations in an Algorithm which as an input took positions on a complete graph.

The repository is here.

So if we want to encode for example two walkers on the graph below, since it has 4 vertices we require 2 qubits to encode the position of each walker. Thus our input will be some state using these 4 qubits. In our case we Hadamarded over all the qubits to distribute the walkers over the whole graph evenly before iteration. This you could say was our state preparation.

Take Home Message Think about how to encode your problem in terms of qubits. This will then allow you to think about what your algorithm is going to act on and so what your input will be and what registers you need and so on.