number generator



I have to generate a list of N random numbers (integer) whose sum is
equal to M. If, for example, I have to generate 5 random numbers whose
sum is 50 a possible solution could be [3, 11, 7, 22, 7]. Is there a
simple pattern or function in Python to accomplish that?

Thanks and regards
Francesco

.



Relevant Pages

  • Re: number generator
    ... simple pattern or function in Python to accomplish that? ... Any finite range of numbers, no matter how big, is a ...
    (comp.lang.python)
  • Re: number generator
    ... simple pattern or function in Python to accomplish that? ...
    (comp.lang.python)
  • Re: number generator
    ... cesco wrote: ... sum is equal to M. ... Is there a simple pattern or function in Python to ...
    (comp.lang.python)
  • Re: number generator
    ... simple pattern or function in Python to accomplish that? ... Not all distinct lists will have the same chance of occurring, e.g. [46, 1, ...
    (comp.lang.python)
  • Re: number generator
    ... simple pattern or function in Python to accomplish that? ... Nth number in the list by one. ...
    (comp.lang.python)