from IPython.display import Image, display
Image('lights_out_rule.png')

Image('lights_out_prob.png')

# The starting pattern is represented by this list of numbers.
# Please use it as an input for your solution.
lights = [0, 1, 1, 1, 0, 0, 1, 1, 1]

def week2a_ans_func(lights):
    ##### build your quantum circuit here
    ####  In addition, please make it a function that can solve the problem even with different inputs (lights). We do validation with different inputs.
    
    return qc

# Submission code
from qc_grader import prepare_ex2a, grade_ex2a, submit_ex2a

# Execute your circuit with following prepare_ex2a() function.
# The prepare_ex2a () function works like the execute() function with only QuantumCircuit as an argument.
job = prepare_ex2a(week2a_ans_func)

result = job.result()
count = result.get_counts()
original_problem_set_counts = count[0]

original_problem_set_counts
# The bit string with the highest number of observations is treated as the solution.

# Check your answer by executing following code.
# The quantum cost of the QuantumCircuit is obtained as the score. The quantum cost is related to rank only in the third week.
grade_ex2a(job)

# Submit your results by executing following code. You can submit as many times as you like during the period. 
submit_ex2a(job)