On Wed, Oct 21, 2026 at 20:48:28 +0200, Nicolas George wrote: > By the way, it seems what you want is not just distinct elements but all > the elements too: a permutation. For that, there is a much more > efficient algorithm: swap the first element randomly with any of the > elements, then the second with any of the elements except the first, > etc.
I didn't get that impression from his code, but if he really does want his playlist to be the same size, or nearly the same size, as his full library of selections, then shuffling the array is the way to go for sure. You don't want to be in a situation where you're generating random numbers waiting for that last song out of 10,000 songs to be chosen.

