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

from qiskit import QuantumCircuit
from qiskit.visualization import visualize_transition
import numpy as np

# build the quantum circuit
q = QuantumCircuit(1)

# init the state
q.h(0)
q.rz(np.pi/2,0)
# already |0>

# apply transformation
q.rz(0, 0)
q.rx(np.pi/2, 0)
q.ry(0, 0)

visualize_transition(q)

def generate_bloch_operation(state):
    rotation = [0,0,0]
    ### Your code goes here 
    if(state=='1'):
        rotation=[0,0,-2]
    elif(state=='+'):
        rotation=[0,0,-1]
    elif(state=='-'):
        rotation=[0,0,1]
    elif(state=='r'):
        rotation=[0,1,0]
    elif(state=='l'):
        rotation=[0,-1,0]
    
    ### Your code goes here 
    
    return rotation 

def test_function_1():
    state = '+'
    
    rotation = generate_bloch_operation(state)
    
    return rotation

test_function_1()

from grader.graders.problem_3.grader import grader1 
grader1.evaluate(generate_bloch_operation)

def get_total_bloch_ops(state, arz, arx, ary):
    total = 0
    qc=QuantumCircuit(1)
    ### Your code goes here 
    for i in arz:
        for j in arx:
            for k in ary:
                qc.reset(0)
                if(state=='1'):
                    qc.x(0)
                elif(state=='+'):
                    qc.h(0)
                elif(state=='-'):
                    qc.x(0)
                    qc.h(0)
                elif(state=='r'):
                    qc.h(0)
                    qc.rz(np.pi/2,0)
                elif(state=='l'):
                    qc.h(0)
                    qc.rz(-np.pi/2,0)
                qc.rz(i*np.pi/2,0)
                qc.rx(j*np.pi/2,0)
                qc.ry(k*np.pi/2,0)
    ### Your code goes here 
    
    return total

def test_function_2():
    # say we have these arrays
    arz = [2]
    arx = [-2]
    ary = [0, 2]

    # initial state is |0>
    state = '0'
    
    # your function would return these two things
    total = get_total_bloch_ops(state, arz, arx, ary)
    
    return total

test_function_2()

from grader.graders.problem_3.grader import grader2
grader2.evaluate(get_total_bloch_ops)

def get_larger_total_bloch_ops(state, arz, arx, ary):
    total = 0 
    ### Your code goes here 
    
    
    ### Your code goes here 
    
    return total

def test_function_3():
    # say we have these arrays
    arz = [2]
    arx = [-2]
    ary = [0, 2]

    # initial state is |0>
    state = '0'

    # your function would return these two things
    total = get_larger_total_bloch_ops(state, arz, arx, ary)
    
    return total

test_function_3()

from grader.graders.problem_3.grader import grader3
grader3.evaluate(get_larger_total_bloch_ops)

