dimanche 4 août 2019

List of length n with p randomly allocated ones else zero

What's the shortest way (as in short code) to get a list of length n with p < n randomly allocated ones else zero. Say n = 6 and p = 2, I'd like something like [0,1,0,0,1,0].




Aucun commentaire:

Enregistrer un commentaire