from qiskit import *
from qiskit.tools.jupyter import *
from qiskit.visualization import *
import matplotlib.pyplot as plotter
import numpy as np
from IPython.display import display, Math, Latex
%matplotlib inline
# Loading your IBM Q account(s)
provider = IBMQ.load_account()

def run_circuit(qc):
    backend = Aer.get_backend('qasm_simulator') # we choose the simulator as our backend
    result = execute(qc, backend, shots = 200000).result() # we run the simulation
    counts = result.get_counts() # we get the counts
    return counts

THE ONLY TASK

qc1 = QuantumCircuit(2,2)
# preparing 'a' bell pair which is |beta_00> here
qc1.h(0)
qc1.cx(0,1)
qc1.barrier([0,1])

# Apply any pauli gate here
a = input("BE SKYLER. APPLY ANY OF THE FOUR PAULI GATES:")
if a == 'X':
    qc1.x(1) 
if a == 'Y':
    qc1.y(1)
if a == 'Z':
    qc1.z(1)
# if it's not any of them, it's I. So we don't need to do anything.
qc1.barrier([0,1])

# Change the state into standard states: |00>, |01>, |10>, |11> depending on the gate applied
qc1.cx(0,1)
qc1.h(0)

#Measure
qc1.measure([0,1],[0,1])
backend = Aer.get_backend('qasm_simulator')
result = execute(qc1, backend, shots = 1024).result()
counts = result.get_counts()
plot_histogram(counts)

# On observation we get this mapping
print('Skyler applied this gate: ')
if '00' in counts.keys():
    print('I') # She bluffed.  # Don't worry if you haven't considered this case. Happens.
elif '10' in counts.keys():
    print('X')
elif '11' in counts.keys():
    print('Y')
else:
    print('Z')
plot_histogram(counts)

