mardi 5 juin 2018

How to shuffle n elements in array in rails?

Let

example = [1,2,3,4,5,6,7,8,9]

Want to shuffle first 5 elements. Other elements have to remains in same index, e.g.:

[2,4,1,3,5,6,7,8,9]
[3,1,4,5,2,6,7,8,9]
# etc

Aucun commentaire:

Enregistrer un commentaire