mardi 14 mars 2023

Multiple random outputs from same pool

I need to have 3 output variables with values from 1 to x, and I need them all to equal 3+y.

If my variables are called "A, B, C" my code is as follows:

A=1
B=1
C=1

while y>0:
A=A+randint(0,y)
y=y-A+1
B=B+randint(0,y)
y=y-B+1
C=C+randint(0,y)
y=y-C+1

This had the problem that it doesn't give all 3 outputs a fair chance, and i also have not found a way to check for x.

Any ideas, even incomplete ones will be welcome, thanks a lot.




Aucun commentaire:

Enregistrer un commentaire