Before you complain, I know that this question has already been asked. But, one, it was in Java and C#, two languages I don’t know, and two, I am asking about whole numbers, while the older one is about floating points, which I do not want or need. I specifically need whole numbers. Thus this problem is completely different from the other one asked, and would require a completely different solution. As the other was specifically made for floating points.
I need an algorithm that can get Pseudo-random values for N variables, each between A and B, which sum up to a sum of M.
For example. [1,2,3,4,5,6,7,8,9,10] = 55, or [10,10,5,9,8,1,2,3,5,2] = 55.
How would I go about doing this in Python?
And yes, I know this would limit degrees of freedom of the randomness. I do not mind that. I just need a way to solve this conundrum.
Also, A and B are both positive integers, no negative numbers and no 0.
DanceroftheStars is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2