my_list = [1, 3, 5, 6, 7, 9, 10, 3]

def the_oracle(my_input):
    winner = 7
    return my_input is winner

for index, trial_number in enumerate(my_list):
    if the_oracle(trial_number) is True:
        print("Winner found at index: %i"%index)
        print("%i calls to the Oracle used"%(index+1))
        break

from qiskit import *
import matplotlib.pyplot as plt
import numpy as np

# define the oracle circuit
oracle = QuantumCircuit(2, name="oracle")
oracle.cz(0,1)
oracle.to_gate()
oracle.draw()

backend = Aer.get_backend("statevector_simulator")
grover_circ = QuantumCircuit(2, 2)
grover_circ.h([0, 1])
grover_circ.append(oracle, [0, 1])
grover_circ.draw()

job = execute(grover_circ, backend)
result = job.result()

sv = result.get_statevector()
np.around(sv, 2)

reflection = QuantumCircuit(2, name="reflection")
reflection.h([0, 1])
reflection.z([0, 1])
reflection.cz(0, 1)
reflection.h([0, 1])
reflection.to_gate()

reflection.draw()

backend = Aer.get_backend("qasm_simulator")
grover_circ = QuantumCircuit(2,2)
grover_circ.h([0, 1])
grover_circ.append(oracle, [0, 1])
grover_circ.append(reflection, [0, 1])
grover_circ.measure([0, 1], [0, 1])

grover_circ.draw()

job = execute(grover_circ, backend, shots = 10000)
result = job.result()
result.get_counts()

