lundi 26 avril 2021

Random numbers with given range AND given sum [closed]

I know there are a lot of similar questions like this but none of them matches my problem exactly. So i would like to generate 6 random numbers, each of them are in the range of 1-8 AND their sum is 18.

[8, 1, 1, 1, 1, 6] would be a good (but quite extreme) example.

Edit:

I'm looking for an algorithm that would do this similar to: generate random integers with a specific sum

P.S.: I would like to implement this in java




Aucun commentaire:

Enregistrer un commentaire