from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, IBMQ, BasicAer
from qiskit.visualization import plot_histogram
from qiskit.quantum_info import Statevector
import numpy as np 
import matplotlib

style = {'backgroundcolor': 'lightyellow'} # Style of the circuits
backend = BasicAer.get_backend('qasm_simulator')
shots = 1024

qreg = QuantumRegister(6)
register1 = ClassicalRegister(5) 

qc = QuantumCircuit(qreg, register1 )

qc.x(5)
qc.barrier()
qc.draw(output='mpl', style=style) 

qc.h(0)
qc.h(1)
qc.h(2)
qc.h(3)
qc.h(4)
qc.h(5)
qc.barrier()
qc.draw(output='mpl', style=style) 

qc.cx(0,5)
qc.cx(1,5)
qc.cx(4,5)
qc.barrier()
qc.draw(output='mpl', style=style) 

qc.h(0)
qc.h(1)
qc.h(2)
qc.h(3)
qc.h(4)
qc.h(5)
qc.barrier()
qc.draw(output='mpl', style=style) 

qc.measure(0, register1[0])
qc.measure(1, register1[1])
qc.measure(2, register1[2])
qc.measure(3, register1[3])
qc.measure(4, register1[4])
qc.draw(output='mpl', style=style)

results = execute(qc, backend=backend, shots=shots).result()
answer = results.get_counts()

plot_histogram(answer)

