import numpy as np
# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
#from ibm_quantum_widgets import *

# Loading your IBM Q account(s)
provider = IBMQ.load_account()

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

n=4
grover_ckt = QuantumCircuit(n+1, n)
marked = [1,0,1,1] # 1101 element is marked (lsb to msb)=>13

def apply_oracle(n,marked,ckt):
    control0 = [i for i in range(n) if not marked[i]]
    ckt.x(control0)
    ckt.mct(list(range(n)),n)
    ckt.x(control0)
    ckt.draw()    

#option A
def reflect_uniform(ckt,n):
    ckt.h(list(range(n)))
    ckt.x(list(range(n)))
    ckt.mct(list(range(n)),n)
    ckt.x(list(range(n)))
    ckt.h(list(range(n)))
    ckt.x(n)

#Test option A
qc=QuantumCircuit(5)
reflect_uniform(qc,4)
qc.draw()