from qiskit import *

circuit = QuantumCircuit(3,3)
%matplotlib inline
circuit.draw(output='mpl')


circuit.x(0) 
circuit.barrier()
circuit.draw(output='mpl')

circuit.h(1)
circuit.cx(1,2)
circuit.barrier()
circuit.draw(output='mpl')

circuit.cx(0,1)
circuit.h(0)
circuit.barrier()
circuit.draw(output='mpl')

circuit.measure([0, 1], [0, 1]) 
circuit.barrier() 
circuit.draw(output='mpl')

circuit.cx(1, 2)
circuit.cz(0, 2)
circuit.measure([2], [2])

circuit.draw(output='mpl')

simulator = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=simulator, shots=1024).result()
from qiskit.visualization import plot_histogram
plot_histogram(result.get_counts(circuit))

# Quantum Computer

from qiskit import IBMQ

IBMQ.save_account('e9857a49c124d22110b0c577754d160e984ce3f01e5ef110ae6295f3f6c4a6f337a129dfdcb5a1191a9b8c69317e9ae32ed4d196b744571d45453db7fb56d933')

IBMQ.load_account()

provider = IBMQ.get_provider(hub = 'ibm-q')

qcomp = provider.get_backend('ibm_brisbane')

import qiskit.tools.jupyter
%qiskit_job_watcher

job = execute(circuit, backend=qcomp)

result = job.result()
plot_histogram(result.get_counts(circuit))

from qiskit import *
circuit = QuantumCircuit(3,3)
%matplotlib inline
circuit.draw(output='mpl')

circuit.x(0) 
circuit.barrier()
circuit.draw(output='mpl')
circuit.h(1)
circuit.cx(1,2)
circuit.barrier()
circuit.draw(output='mpl')
circuit.cx(0,1)
circuit.h(0)
circuit.barrier()
circuit.draw(output='mpl')
circuit.measure([0, 1], [0, 1]) 
circuit.barrier() 
circuit.draw(output='mpl')
circuit.cx(1, 2)
circuit.cz(0, 2)
circuit.measure([2], [2])
circuit.draw(output='mpl')
simulator = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=simulator, shots=1024).result()
from qiskit.visualization import plot_histogram
plot_histogram(result.get_counts(circuit))
# Quantum Computer
from qiskit import IBMQ
IBMQ.save_account('e9857a49c124d22110b0c577754d160e984ce3f01e5ef110ae6295f3f6c4a6f337a129dfdcb5a1191a9b8c69317e9ae32ed4d196b744571d45453db7fb56d933')
IBMQ.load_account()
provider = IBMQ.get_provider(hub = 'ibm-q')
qcomp = provider.get_backend('ibm_brisbane')
import qiskit.tools.jupyter
%qiskit_job_watcher
job = execute(circuit, backend=qcomp)
result = job.result()
plot_histogram(result.get_counts(circuit))