import qiskit
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import Aer

import numpy as np
from math import floor, ceil

%matplotlib inline

def max_number(arr_size):
    return (2 ** arr_size)-1

def check_min_circuit(a, threshold):
    max = max_number(a)
    foo = max - threshold
    binary = format(foo, 'b')[::-1]
    print(binary)
    extra = a - len(binary)
    for i in range(extra):
            binary = "0" + binary
    print(binary)
    for i in range(a):
        if int(binary[i])==1:
            qc1.x(_q[i])

_q = QuantumRegister(5)
qc1 = QuantumCircuit(_q)
check_min_circuit(5, 20)
qc1.draw()

