from qiskit import (QuantumCircuit, execute, Aer)
from functools import partial

default_backend = Aer.get_backend('qasm_simulator')

def run_qc_using_backend(backend, qc):
    job = execute(qc, backend)
    return job.result()

def get_quantum_random_bitstring(sz=1, dump_circuit=False, runner = partial(run_qc_using_backend, default_backend)):
    
    qc = QuantumCircuit(sz,sz)

    for ch in range(sz):
        qc.h(ch)
        qc.measure([ch],[ch])

    if dump_circuit:
        return qc
    else:
        return runner(qc)

t = get_quantum_random_bitstring(8,dump_circuit=True)
t.draw('mpl')

from random import randint,sample
def get_random_bitstring(sz):
    return [randint(0,1) for i in range(sz)]

t = get_random_bitstring(16)
print(t)

