I am trying to use the following function:
random.randint()
to generate a series of numbers that should equal the input() integer. The only problem here is, that I tried doing it through a "while if" loop. wherein the loop keeps generating numbers till the random combination equals n = int(input()). However, this method is very consuming and sometimes it takes up to an entire minute for the pycharm to find a correct combination. Are there already made functions to solve this problem?
Edit
I will add the code as requested but yeah the code is huge because of the variables. The reason the range is from (1, a) is because a range of (0, a) causes error from random module.
I tried the same block of codes but with other variables to generate something different like an income statement with a range (0, a) and it worked totally fine, I don't know why the range (0, a) sometimes work and sometimes not.
# Cash
ca = 0
# Marketable securities
ms = 0
# Accounts receivable
ar = 0
# Inventories
i = 0
# Total current assets
tca = 0
# Land and buildings
lab = 0
# Machinery and equipment
mae = 0
# Furniture and fixtures
faf = 0
# Vehicles
v = 0
# Other (includes financial leases)
ot = 0
# Total gross fixed assets
tgfa = 0
# Less: Accumulated depreciation
ad = 0
# Net fixed assets
nfa = 0
# Total assets
ta = 0
# Accounts payable
ap = 0
# Notes payable
npp = 0
# Accruals
acc = 0
# Total current liabilities
tcl = 0
# Long-term debt (includes financial leases)
ltd = 0
# Total liabilities
tl = 0
# Preferred stock
ps = 0
# Common stock
cs = 0
# Paid-in capital in excess of par on common stock
pic = 0
# Retained earnings
re = 0
# Total stockholders’ equity
tse = 0
# Total liabilities and stockholders’ equity
tlase = 0
while ta <= 0 and 0 >= tlase:
    ca += random.randint(1,a)
    ms += secrets.randbelow(ca)
    ar += secrets.randbelow(ca)
    i += secrets.randbelow(ca)
    lab += random.randint(1,a)
    mae += random.randint(1,a)
    faf += secrets.randbelow(ca)
    v += secrets.randbelow(ca)
    ot += secrets.randbelow(ca)
    ad += secrets.randbelow(ca)
    ap += secrets.randbelow(ca)
    npp += secrets.randbelow(ca)
    acc += secrets.randbelow(ca)
    ltd += random.randint(1,a)
    ps += secrets.randbelow(ca)
    cs += secrets.randbelow(ca)
    pic += secrets.randbelow(ca)
    re += random.randint(1,a)
    tca += ca + ms + ar + i
    tgfa += lab + mae + faf + v + ot
    nfa += tgfa - ad
    ta += tgfa - (ad + ca + ms + ar + i)
    tcl += ap + npp + acc
    tl += tcl + ltd
    tse += ps + cs + pic + re
    tlase += ps + cs + pic + re + tcl + ltd
    if 0 >= ta and tlase <= 0:
        ca *= 0
        ms *= 0
        ar *= 0
        i *= 0
        lab *= 0
        mae *= 0
        faf *= 0
        v *= 0
        ot *= 0
        ad *= 0
        ap *= 0
        npp *= 0
        acc *= 0
        ltd *= 0
        ps *= 0
        cs *= 0
        pic *= 0
        re *= 0
        tca *= 0
        tgfa *= 0
        nfa *= 0
        ta *= 0
        tcl *= 0
        tl *= 0
        tse *= 0
        tlase *= 0
    elif ta != tlase:
        ca *= 0
        ms *= 0
        ar *= 0
        i *= 0
        lab *= 0
        mae *= 0
        faf *= 0
        v *= 0
        ot *= 0
        ad *= 0
        ap *= 0
        npp *= 0
        acc *= 0
        ltd *= 0
        ps *= 0
        cs *= 0
        pic *= 0
        re *= 0
        tca *= 0
        tgfa *= 0
        nfa *= 0
        ta *= 0
        tcl *= 0
        tl *= 0
        tse *= 0
        tlase *= 0
    else:
        print("true")
 
     
    