import numpy as np

# Import Qiskit
from qiskit import QuantumCircuit
from qiskit import Aer, transpile
from qiskit.tools.visualization import plot_histogram, plot_state_city
from qiskit import *
from qiskit.tools.monitor import job_monitor

import qiskit.quantum_info as qi

Aer.backends()
simulator = Aer.get_backend('aer_simulator')


# Set initial state to generated statevector
circ = QuantumCircuit(7, 6)
circ.x(6)
circ.barrier()
circ.h(0)
circ.h(1)
circ.h(2)
circ.h(3)
circ.h(4)
circ.h(5)
circ.h(6)
circ.barrier()
circ.x(2)
circ.cx(3,6)
circ.cx(0,6)
circ.cx(5,6)
circ.x(3)
circ.cx(3,6)
circ.x(0)
circ.barrier()
circ.h(0)
circ.h(1)
circ.h(2)
circ.h(3)
circ.h(4)
circ.h(5)
circ.h(6)
circ.barrier()
circ.measure(range(6), range(6))
circ.draw()

# execute the quantum circuit
backend = BasicAer.get_backend('qasm_simulator') # the device to run on
result = backend.run(transpile(circ, backend), shots=1000).result()
counts  = result.get_counts(circ)
print(counts)

plot_histogram(counts)