vendredi 6 juillet 2018

Generating fixed length sequence of numbers bounded by k that add up to n

Given positive integers l, k and n, I am interested in writing a function f(l, k, n), that returns a randomly generated sequence of length l of integers in -k, -k + 1, ..., -1, 0, 1, ..., k - 1, k that add up to n.

Any ideas how one could achieve this?




Aucun commentaire:

Enregistrer un commentaire