from qiskit import *
%matplotlib inline
from qiskit.tools.visualization import plot_histogram

secretNumber = '111000'

circuit =  QuantumCircuit(len(secretNumber)+1, len(secretNumber))
circuit.h(range(len(secretNumber)))
circuit.x(len(secretNumber))
circuit.h(len(secretNumber))
circuit.barrier()

for ii, yesno in enumerate(reversed(secretNumber)):
    if yesno == '1':
        circuit.cx(ii, len(secretNumber))


circuit.barrier()

circuit.h(range(len(secretNumber)))

circuit.barrier()

circuit.measure(range(len(secretNumber)),range(len(secretNumber)))

circuit.draw(output="mpl")

simulator = Aer.get_backend('qasm_simulator')
result = execute(circuit,backend = simulator, shots=1).result()
counts = result.get_counts()
print(counts)