I have to create an array in Python with random elements, random numbers of elements. The only important thing is that: the size should be equal to the sum of all elements.
Examples: range of elements min=1
, max=1024
, sum=1024
.
- case:
[1000, 13, 11]
, 3 elements, their sum is1024
. - case:
[500, 200, 100, 2, 22, 150, 50]
, 7 elements, their sum is1024
.
It doesn't matter if there are identical number [512, 512]
. Can someone explain me how to do that?
Aucun commentaire:
Enregistrer un commentaire