## Enter Team ID 
import os 
os.environ["TEAMID"] = "Excalibur"

from qiskit import QuantumCircuit
def dj_circuit_2q(oracle):
    
    dj_circuit = QuantumCircuit(3,2)
    ### Your code here 
    dj_circuit.x(2)
    dj_circuit.barrier()
    dj_circuit.h(range(3))
    dj_circuit.barrier()
    dj_circuit.compose(oracle, inplace = True)
    dj_circuit.barrier()
    dj_circuit.h(range(2))
    dj_circuit.measure(range(2), range(2))
    ### Your code here 
    
    return dj_circuit

def test_function_1():
    # a constant oracle with f(x)=0 for all inputs 
    oracle = QuantumCircuit(3)
    oracle.id(2)
    
    dj_circuit = dj_circuit_2q(oracle)
    
    return dj_circuit

test_function_1().draw()

from grader.graders.problem_4.grader import grader1 
grader1.evaluate(dj_circuit_2q)

def dj_circuit_4q(oracle):
    
    circuit = QuantumCircuit(5, 4)
    ### Your code here 
    circuit.x(4)
    circuit.barrier()
    circuit.h(range(5))
    circuit.barrier()
    circuit.compose(oracle, inplace = True)
    circuit.barrier()
    circuit.h(range(4))
    circuit.measure(range(4), range(4))
    ### Your code here 
    
    return circuit

def test_function_2():
    oracle = QuantumCircuit(5)
    oracle.id(4)
    
    dj_circuit = dj_circuit_4q(oracle)
    
    return dj_circuit

test_function_2().draw()

from grader.graders.problem_4.grader import grader2
grader2.evaluate(dj_circuit_4q)

from qiskit import QuantumCircuit 

def dj_circuit_general(n, oracle):
    
    dj_circuit = QuantumCircuit(n+1, n)
    ### Your code here 
    dj_circuit.x(n)
    dj_circuit.barrier()
    dj_circuit.h(range(n+1))
    dj_circuit.barrier()
    dj_circuit.compose(oracle, inplace = True)
    dj_circuit.barrier()
    dj_circuit.h(range(n))
    dj_circuit.measure(range(n), range(n))
    ### Your code here 
    
    return dj_circuit

def test_function_3():
    N = 6
    
    # constant oracle with f(x) = 0
    oracle = QuantumCircuit(7)
    oracle.id(6)
    
    circuit = dj_circuit_general(N, oracle)
    
    return circuit

test_function_3().draw()

from grader.graders.problem_4.grader import grader3
grader3.evaluate(dj_circuit_general)

