%run init.ipynb

from qiskit import *
nshots = 8192
IBMQ.load_account()
provider = IBMQ.get_provider(hub = 'ibm-q-research-2', group = 'federal-uni-sant-1', project = 'main')
simulator = Aer.get_backend('qasm_simulator')
device = provider.get_backend('ibm_nairobi')
from qiskit.tools.visualization import plot_histogram
from qiskit.tools.monitor import job_monitor, backend_overview, backend_monitor

qr = QuantumRegister(4); cr = ClassicalRegister(4); qc = QuantumCircuit(qr,cr)
qc.h([0,1])
qc.barrier()
qc.cx(0,2); qc.cx(0,3); qc.cx(1,2); qc.cx(1,3) # oraculo
qc.barrier()
qc.measure([2,3],[2,3])
qc.barrier()
qc.h([0,1]); qc.measure([0,1],[0,1])
qc.draw(output='mpl')

jobS = execute(qc, backend = simulator, shots = nshots)

jobE = execute(qc, backend = device, shots = nshots)
job_monitor(jobE)

plot_histogram([jobS.result().get_counts(0), jobE.result().get_counts(0)], 
               bar_labels = False, legend = ['sim', 'exp'])





